我使用的是PrimeFaces Calendar组件。但我想用土耳其语显示时间和月份。我写了这样的代码;
< p:calendar effect="slideDown" navigator="true" locale="tr"
yearRange="1975" pattern="dd/mm/yyyy HH:mm"/>
但它再次以英文显示。问题是什么?
答案 0 :(得分:20)
Primefaces本身仅为calendar这样的可本地化组件提供英语翻译。如果您需要其他翻译,您必须通过JavaScript手动将它们包含在您的JSF中。
将以下JavaScript添加到您的JSF视图中:
<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>
另见:
http://code.google.com/p/primefaces/wiki/PrimeFacesLocales
编辑:
PrimeFaces转移到github,所以这里是新的URL(即使旧的URL仍然可用):
https://github.com/primefaces/primefaces/wiki/Locales
答案 1 :(得分:0)
primefaces_i18n.js
文件夹中创建文件resources/js
。然后您可以将其导入页面中,如下所示:
<h:outputScript library="js" name="primefaces_i18n.js" />