Jakarta ee 语境中的i18n意义

Jakarta ee 语境中的i18n意义,jakarta-ee,xhtml,Jakarta Ee,Xhtml,在我看到的一段代码片段中,我想了解i18n(国际化)在代码中的用法..谁能简单地向我解释一下它为什么存在。。我只是想了解为什么会有“i18n.createTitle”,这是不是意味着,它将语言翻译成英语的国际化,还是什么?这可能是个愚蠢的问题,但我是个新手..谢谢 <ui:composition template="/_decorator.xhtml"> <ui:define name="title">#{i18n.createTitle}</ui:defi

在我看到的一段代码片段中,我想了解i18n(国际化)在代码中的用法..谁能简单地向我解释一下它为什么存在。。我只是想了解为什么会有“i18n.createTitle”,这是不是意味着,它将语言翻译成英语的国际化,还是什么?这可能是个愚蠢的问题,但我是个新手..谢谢

<ui:composition template="/_decorator.xhtml">
    <ui:define name="title">#{i18n.createTitle}</ui:define>
    <ui:define name="heading">#{i18n.createHeading}</ui:define>
    <ui:define name="body">

#{i18n.createTitle}
#{i18n.createHeading}

简而言之:每种语言都有一个属性文件。在这些文件中,每个文本都有一个标签。例如:

i18n_ES.properties:(西班牙语为ES)

i18n_EN.properties:(英语为英语)

浏览器请求的标题中通常有语言首选项,因此响应使用该首选项来选择文本。如果要支持更多语言,则需要创建更多属性文件

然后可以使用i18n加载属性并请求文本:例如,i18n.helloworld

helloworld=Hola Mundo
share_button=Comparte esta entrada
helloworld=Hello World
share_button=Share this post