Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 629
emreturka Avatar asked Dec 30 '13 15:12

emreturka


2 Answers

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

like image 160
stg Avatar answered Oct 23 '22 03:10

stg


  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
like image 31
madx Avatar answered Oct 23 '22 03:10

madx