Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI Bug] Language not showing properly on scheduled tasks #2637

Open
wtang3 opened this issue Jan 23, 2025 · 0 comments
Open

[UI Bug] Language not showing properly on scheduled tasks #2637

wtang3 opened this issue Jan 23, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@wtang3
Copy link

wtang3 commented Jan 23, 2025

Qinglong version

Qinglong 2.18.1

Steps to reproduce

  1. Navigate to System Settings > Other Settings > Language (Change Language to English)
  2. Navigate to Scheduled Tasks
  3. Create a script
  4. Run script and notice Last Run Duration shows only Chinese duration and not English.

What is expected?

Expected to show English
Image

What is actually happening?

Image

System Info

Linux Ugreen Docker Compose

All Browsers

Any additional comments?

I believe this is happening in file crontab > index.tsx where diffTime is being called.

A quick fix could look something like below, however maybe it might better to rewrite the function so there are not too many magic strings and easier to refactor later? There are two locations the diffTime() is being used so maybe it won't be too difficult to just refactor

before

 render: (text, record) => {
        return record.last_running_time
          ? diffTime(record.last_running_time)
          : '-';
      },

after

 render: (text, record) => {
        return record.last_running_time
          ? diffTimeWithTranslation(record.last_running_time, intl.get)
          : '-';
      },
  import { get } from 'react-intl-universal';

  function diffTimeWithTranslation(num: number, intlGet: typeof get) {
    ...
    .....
    ........

    let returnStr = seconds + intlGet('秒');
  
    if (minutes > 0) {
      returnStr = minutes + intlGet('分') + returnStr;
    }
    if (hours > 0) {
      returnStr = hours +  intlGet('小时') + returnStr;
    }
    if (days > 0) {
      returnStr = days +  intlGet('天') + returnStr;
    }
    return returnStr;
  
  }
@whyour whyour added the bug Something isn't working label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants