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

How to change language #242

Open
Evercosta opened this issue May 26, 2022 · 13 comments
Open

How to change language #242

Evercosta opened this issue May 26, 2022 · 13 comments

Comments

@Evercosta
Copy link

No description provided.

@walkerkay
Copy link
Collaborator

walkerkay commented May 27, 2022

You can configure dateFormat to implement language change

// example :

import { GANTT_GLOBAL_CONFIG } from 'ngx-gantt';

@NgModule({
  providers: [
    {
      provide: GANTT_GLOBAL_CONFIG,
      useValue: {
        dateFormat: {
             yearQuarter: `QQQ 'of' yyyy`,
             month: 'LLLL',
             yearMonth: `LLLL yyyy'(week' w ')'`
        }
      }
    }
  ]
})
export class AppModule {

}

Format rules: https://date-fns.org/v2.28.0/docs/format

@Evercosta
Copy link
Author

@walkerkay Tank you, last question: How changing locale globally?

@walkerkay
Copy link
Collaborator

@walkerkay Tank you, last question: How changing locale globally?

Time zone ? ngx-gantt data uses timestamp.
If you need to show the time, you need to use some pipes to achieve it after obtaining the time in the data.

@romildojpaiter
Copy link

Hello @walkerkay.

Congrats for this project, I liked so much. Could you tell me, how can I set the locale to ptBR in date-fns, to project-wide.

I'm already used GanttViewOptions, dateFormat, but I need put my project as portuguese.

Is this possible?

image

@hnguyen48206
Copy link

I also can not find anywhere to configure the locale of displayed time and the properties of GanttViewOptions do not have the one named dateformat either.

image

@DyegoPimentel
Copy link

How can I translate this:
image

@Theodode
Copy link

Theodode commented Nov 18, 2022

I have the same issue. It seems the GanttDate class doesn't provide any entry points to set date-fns locale option (https://date-fns.org/v2.0.0-alpha.26/docs/Locale). So my week numbering is not ISO, some year have not the right number of weeks.
It is possible now to set default Locale in date-fns (https://date-fns.org/v2.29.0/docs/setDefaultOptions) but only since the version 2.29:

// Set global locale:
import { setDefaultOptions } from 'date-fns';
import { fr } from 'date-fns/locale';
setDefaultOptions({ locale: fr });

Update date-fns to 2.29 is probably the esiest way to solve this issue without touching anything.

@walkerkay
Copy link
Collaborator

I have the same issue. It seems the GanttDate class doesn't provide any entry points to set date-fns locale option (https://date-fns.org/v2.0.0-alpha.26/docs/Locale). So my week numbering is not ISO, some year have not the right number of weeks. It is possible now to set default Locale in date-fns (https://date-fns.org/v2.29.0/docs/setDefaultOptions) but only since the version 2.29:

// Set global locale: import { setDefaultOptions } from 'date-fns'; import { fr } from 'date-fns/locale'; setDefaultOptions({ locale: fr });

Update date-fns to 2.29 is probably the esiest way to solve this issue without touching anything.

Yes, the date format uses date-fns, so you need to import date-fns to set the time zone.

@vladsklov
Copy link

I have the same issue, want to translate month to en. Angular v17
image
image

@akabikas
Copy link

I have the same issue, want to translate month to en. Angular v17 image image

Have you found any solutions yet?

@vladsklov
Copy link

vladsklov commented Sep 10, 2024

I have the same issue, want to translate month to en. Angular v17 image image

Have you found any solutions yet?

only this

translateCalendarToEng(): void {
let svgHTML =
this.el.nativeElement.children[0].children[0].children[0].children[1].children[0].children[1].innerHTML;

for (const [chineseMonth, englishMonth] of Object.entries(CHINES_MONTH_MAP)) {
  const regex = new RegExp(chineseMonth, 'g');
  svgHTML = svgHTML.replace(regex, `${englishMonth}/`);
}

// Remove the "日" character
svgHTML = svgHTML.replace(/日/g, '');

// Replace "没有数据" with "No data"
svgHTML = svgHTML.replace(/没有数据/g, 'No data');
this.el.nativeElement.children[0].children[0].children[0].children[1].children[0].children[1].innerHTML = svgHTML;

// eslint-disable-next-line max-len
this.el.nativeElement.children[0].children[0].children[1].children[0].children[0].children[0].children[0].children[0].children[0].children[1].innerText =
  'No Data';

}

@walkerkay
Copy link
Collaborator

I have the same issue, want to translate month to en. Angular v17 image image

  dateFormat: {
                    day:'MM/dd', // please add it
                    week: 'w',
                    month: 'M',
                    quarter: 'QQQ',
                    year: 'yyyy',
                    yearMonth: 'yyyy MM',
                    yearQuarter: 'yyyy QQQ'
 }

@walkerkay
Copy link
Collaborator

I have the same issue, want to translate month to en. Angular v17 image image

  dateFormat: {
                    day:'MM/dd', // please add it
                    week: 'w',
                    month: 'M',
                    quarter: 'QQQ',
                    year: 'yyyy',
                    yearMonth: 'yyyy MM',
                    yearQuarter: 'yyyy QQQ'
 }

@vladsklov @akabikas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants