IBM / gantt-chart

IBM Gantt Chart Component, integrable in Vanilla, jQuery, or React Framework.
https://ibm.github.io/gantt-chart/packages/ibm-gantt-chart-docs/storybook
Apache License 2.0
214 stars 52 forks source link

How to translate timeline date into japanese ? #52

Closed ZenTal29 closed 2 years ago

ZenTal29 commented 2 years ago

Can someone give me an example to change timeline language to japanese ?

I found this setTimeWindow function at ibm-gantt-chart/jquery/timeline.js that can do this but I haven't figured out how to configure it. Please help me !!

delhoume commented 2 years ago

You may look at https://github.com/IBM/gantt-chart/issues/21 for some info.

ZenTal29 commented 2 years ago

I've read it before, but it's not very clear. Can you help me explain a little more clearly. Or it would be nice if there are basic steps.

delhoume commented 2 years ago

you have const intl = Gantt.utils.getIntl(); if (intl) { if (intl.locale) { momentIntl.locale(intl.locale); } }

so if you use Gantt.utils.setInt(intl) with intl that has a locale field set to 'ja' then it will be used by moment-with-locales.js

ZenTal29 commented 2 years ago

I tried this code in generateDecorations .

const gantt = ctx.gantt; gantt .utils.setIntl('ja');

and

const gantt = ctx.gantt; gantt .utils.setIntl('ja', { weekdays : ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'], months : ['1 月', '2 月', '3 月', '4 月', '5 月', '6 月', '7 月', '8 月', '9 月', '10 月', '11 月', '12 月'] });

but nothing happens except my chart is disabled and not visible anymore. Did I do something wrong at some point and need to configure it somewhere else?

delhoume commented 2 years ago

It seems that it should be gantt.utils.setIntl({ locale : 'ja'} );

no ?

ZenTal29 commented 2 years ago

I tried this code and it works. Thanks for your advice !

gantt.utils.setIntl({locale : 'ja', formatMessage: () => {id: 'ja'}})

delhoume commented 2 years ago

You're welcome !