emreturka
emreturka

Reputation: 876

PrimeFaces locale not working

I am using PrimeFaces Calendar component . But I want to display time and month in Turkish.I have written codes like this;

< p:calendar effect="slideDown" navigator="true"  locale="tr"
                        yearRange="1975" pattern="dd/mm/yyyy HH:mm"/>

But it is displaying again in English.What is the problem?

Upvotes: 6

Views: 21864

Answers (2)

madx
madx

Reputation: 7213

  1. Create a file primefaces_i18n.js inside your resources/js folder.
  2. Copy and paste this gist inside it.
  3. Then you can import it in your page like this:

    <h:outputScript library="js" name="primefaces_i18n.js" />
    
  4. Periodically check PrimeFacesLocales for translation updates

Upvotes: 4

stg
stg

Reputation: 2797

Primefaces itself only provides english translations for localizable components like calendar. If you need other translations you have to include them manually into your JSF via JavaScript.

Add the following JavaScript to your JSF view:

<script type="text/javascript">  
    PrimeFaces.locales['tr'] = {
    closeText: 'kapat',
    prevText: 'geri',
    nextText: 'ileri',
    currentText: 'bugün',
    monthNames: ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'],
    monthNamesShort: ['Oca','Şub','Mar','Nis','May','Haz', 'Tem','Ağu','Eyl','Eki','Kas','Ara'],
    dayNames: ['Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi'],
    dayNamesShort: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
    dayNamesMin: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
    weekHeader: 'Hf',
    firstDay: 1,
    isRTL: false,
    showMonthAfterYear: false,
    yearSuffix: '',
    timeOnlyTitle: 'Zaman Seçiniz',
    timeText: 'Zaman',
    hourText: 'Saat',
    minuteText: 'Dakika',
    secondText: 'Saniye',
    ampm: false,
    month: 'Ay',
    week: 'Hafta',
    day: 'Gün',
    allDayText : 'Tüm Gün'
};
</script>  

See also: http://code.google.com/p/primefaces/wiki/PrimeFacesLocales

EDIT:
PrimeFaces moved to github, so here is the new URL (even though the old one is still available up to now):
https://github.com/primefaces/primefaces/wiki/Locales

Upvotes: 22

Related Questions