PrimeFaces 语言环境不起作用 [英] PrimeFaces locale not working

查看:33
本文介绍了PrimeFaces 语言环境不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PrimeFaces 日历组件.但是我想用土耳其语显示时间和月份.我写了这样的代码;

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?

推荐答案

Primefaces 本身只为诸如 日历.如果您需要其他翻译,您必须通过 JavaScript 手动将它们包含到您的 JSF 中.

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.

将以下 JavaScript 添加到您的 JSF 视图中:

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>  

另见:http://code.google.com/p/primefaces/wiki/PrimeFacesLocales


PrimeFaces 移到 github,所以这里是新的 URL(即使旧的到现在仍然可用):
https://github.com/primefaces/primefaces/wiki/Locales

这篇关于PrimeFaces 语言环境不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆