Highcharts DateTime Localization

2019-03-09 06:44发布

Can someone point me to how I can localize the date-related Strings which are hardcoded in the HighCharts js-file. For instance, instead of the default 'Feb' date label in the x-axis, I would want the chart to display the localized value 'Fév'. I tried implementing the localization by setting the options on the language object before the chart is instantiated:

Highcharts.setOptions({
lang: {
    months: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
    weekdays: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi']
} });

but the chart still displays the default values.

jsFiddle with the problem.

19条回答
别忘想泡老子
2楼-- · 2019-03-09 07:19

Hungarian (magyar):

lang: {
    loading: 'Betöltés...',
    months: ['január', 'február', 'március', 'április', 'május','június',
        'július', 'augusztus', 'szeptember', 'október', 'november', 'december'],
    shortMonths:  ['jan', 'febr', 'márc', 'ápr', 'máj', 'jún', 'júl', 'aug', 'szept', 'okt', 'nov', 'dec'],
    weekdays: ['vasámap', 'hétfő', 'kedd', 'szerda', 'csütörtök', 'péntek', 'szombat'],                     
    exportButtonTitle: "Exportál",
    printButtonTitle: "Importál",
    rangeSelectorFrom: "ettől",
    rangeSelectorTo: "eddig",
    rangeSelectorZoom: "mutat:",
    downloadPNG: 'Letöltés PNG képként',
    downloadJPEG: 'Letöltés JPEG képként',
    downloadPDF: 'Letöltés PDF dokumentumként',
    downloadSVG: 'Letöltés SVG formátumban',
    resetZoom: "Visszaállít",
    resetZoomTitle: "Visszaállít",
    thousandsSep: "",
    decimalPoint: ','
},
rangeSelector: {
      buttons: [
        { count: 1, type: 'month', text: '1 hó'}, 
        { count: 3, type: 'month', text: '3 hó'},
        { count: 6, type: 'month', text: '6 hó'},
        { count: 1, type: 'year' , text: '1 év'},
        { type: 'all', text: 'mind'}
    ],
    inputEnabled: false,
    selected: 0
},

note for all: weekdays starts from Sunday!

查看更多
贼婆χ
3楼-- · 2019-03-09 07:20

In French:

Highcharts.setOptions({
        lang: {
                loading: 'Chargement...',
                months: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
                weekdays: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
                shortMonths: ['jan', 'fév', 'mar', 'avr', 'mai', 'juin', 'juil', 'aoû', 'sep', 'oct', 'nov', 'déc'],
                exportButtonTitle: "Exporter",
                printButtonTitle: "Imprimer",
                rangeSelectorFrom: "Du",
                rangeSelectorTo: "au",
                rangeSelectorZoom: "Période",
                downloadPNG: 'Télécharger en PNG',
                downloadJPEG: 'Télécharger en JPEG',
                downloadPDF: 'Télécharger en PDF',
                downloadSVG: 'Télécharger en SVG',
                resetZoom: "Réinitialiser le zoom",
                resetZoomTitle: "Réinitialiser le zoom",
                thousandsSep: " ",
                decimalPoint: ','
        }
});
查看更多
仙女界的扛把子
4楼-- · 2019-03-09 07:21

In italiano

var highchartsOptions = Highcharts.setOptions({
lang: 
    {
    loading: 'Sto caricando...',
    months: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
    weekdays: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'],
    shortMonths: ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lugl', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'],
    exportButtonTitle: "Esporta",
    printButtonTitle: "Importa",
    rangeSelectorFrom: "Da",
    rangeSelectorTo: "A",
    rangeSelectorZoom: "Periodo",
    downloadPNG: 'Download immagine PNG',
    downloadJPEG: 'Download immagine JPEG',
    downloadPDF: 'Download documento PDF',
    downloadSVG: 'Download immagine SVG',
    printChart: 'Stampa grafico',
    thousandsSep: ".",
    decimalPoint: ','
    }
});
查看更多
爷的心禁止访问
5楼-- · 2019-03-09 07:22

Russian translation for highchart

Русский перевод для highchart

Highcharts.setOptions({
        lang: {
            months: ['Январь', 'Февраль', 'Март', 'Апрель',
                'Май', 'Июнь', 'Июль', 'Август',
                'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
            weekdays: ['Воскресенье', 'Понедельник', 'Вторник',
                'Среда', 'Четверг', 'Пятница', 'Суббота'],
            shortMonths: ['Январь', 'Февраль', 'Март', 'Апрель',
                'Май', 'Июнь', 'Июль', 'Август',
                'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь']
        }
    });
查看更多
乱世女痞
6楼-- · 2019-03-09 07:23

To localize weekdays, Highcharts.setOptions should be called before chart creation and contain the new weekday names:

Highcharts.setOptions({
    lang: {
        weekdays: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi']
} });

Note that the array should start with the name for Sunday not Monday (the first day of the work week).

Example on jsFiddle

enter image description here

查看更多
闹够了就滚
7楼-- · 2019-03-09 07:23

For Turkish (Türkçe olarak):

var highchartsOptions = Highcharts.setOptions({
  lang: {
        loading: 'Yükleniyor...',
        months: ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran',  'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'],
        weekdays: ['Pazar', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'],
        shortMonths: ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran',  'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'],
        exportButtonTitle: "Dışarı Aktar",
        printButtonTitle: "Yazdır",
        rangeSelectorFrom: "Başlangış",
        rangeSelectorTo: "Bitiş",
        rangeSelectorZoom: "Periyot",
        downloadPNG: 'PNG Olarak indir',
        downloadJPEG: 'JPEG olarak indir',
        downloadPDF: 'PDF olarak indir',
        downloadSVG: 'SVG olarak indir',
        resetZoom: ['Yakınlaşmayı Sıfırla'],
        resetZoomTitle:['Yakınlaşmayı Sıfırla'],
        printChart:['Yazdır']
        // thousandsSep: ".",
        // decimalPoint: ','
        }
});
查看更多
登录 后发表回答