ITeye博客

ofbiz国际化资源文件及uiLabelMap使用

anhuiqm · 2011-08-31 17:50 · ofbiz · Markdown

ofbiz11.04中国际化资源文件使用的是xml。 平常的时候我们在java中UtilProperties.getMessage("CommonUiLabels","CommonFtpFileCannotBeOpen", locale)获取CommonUiLabels这个资源文件的CommonFtpFileCannotBeOpen的内容。 在xml中我们先得到uiLabelMap这个map然后用${uiLabelMap.CommonFtpFileCannotBeOpen}获取CommonUiLabels这个资源文件的CommonFtpFileCannotBeOpen的内容。 但是在一些特殊情况下使用国际化资源文件有一些些小小细节,例如: 1.form中使用和来自动生成field的时候,这个时候我们无法使用${uiLabelMap.*}给每个field指定title。但是我们可以在资源文件写FormFieldTitle_runStatusId意思是Form里面name为runStatusId的field的Title的内容。完整代码如下:

<property key="FormFieldTitle_runStatusId">
        <value xml:lang="de">Laufzeitstatus ID</value>
        <value xml:lang="en">Run Status Id</value>
        <value xml:lang="fr">Réf. de statut en cours</value>
        <value xml:lang="it">Stato Esecuzione</value>
        <value xml:lang="pt">ID de estado de execução</value>
        <value xml:lang="ro">Stat Executie</value>
        <value xml:lang="th">ดำเนินการรหัสสถานะ</value>
        <value xml:lang="zh">运行状态标识</value>
        <value xml:lang="zh_TW">執行狀態ID</value>
    </property>

2.ftl中的js要使用国际化资源文件是我们通常用${uiLabelMap.CommonFtpFileCannotBeOpen}获取,这个时候中文的字符串是经过html转义之后的字符串。当我们在js中直接使用的时候就是这样一堆经过转义之后的字符串,例如alert出来的时候就是html转义后的字符串。如果我们想在这个时候得到的是资源文件里面的内容的时候我们可以用${StringUtil.wrapString(uiLabelMap.CommonFtpFileCannotBeOpen)}。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。