Search code examples
jakarta-eeprimefacesjsf-2

How to localize timeline component from primefaces


I want to use a timeline component from the Primefaces

<p:timeline id="timeline" value="#{dashboardBean.model}" height="250px"
                                    locale="cs_CZ"
     ...

</p:timeline>

I have defined a locale in JS which work correctly for a Calendar component. Nevertheless I am not able to make it work for the timeline.

PrimeFaces.locales ['cs_CZ'] = {
    closeText: 'Zavřít',
    prevText: 'Předchozí',
    nextText: 'Následující',
...
};

Any advice would be much appreciated.


Solution

  • I figure it out. TimeLine is based on chap links library. You need to create a javascript code which looks like this:

    if (typeof links === 'undefined') {
        links = {};
        links.locales = {};
    } else if (typeof links.locales === 'undefined') {
        links.locales = {};
    }
    
    links.locales['cz'] = {
        'MONTHS': ["Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Zaří", "Říjen", "Listopad", "Prosinec"],
        'MONTHS_SHORT': ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
        'DAYS': ["Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota"],
        'DAYS_SHORT': ["Ne", "Po", "Út", "St", "Čt", "Pá", "So"],
        'ZOOM_IN': "Přiblížit",
        'ZOOM_OUT': "Oddálit",
        'MOVE_LEFT': "Doleva",
        'MOVE_RIGHT': "Doprava",
        'NEW': "Nový",
        'CREATE_NEW_EVENT': "Vytvořit novou akci"
    };
    

    In jsf:

     <p:timeline id="timeline" value="#{dashboardBean.model}" height="250px"
                                            locale="cz"
             ...
    
        </p:timeline>