|
|
|
注意,一个系统中只能选择使用一种类型的属性格式文件,不能混合普通属性.properties及xml格式属性文件,EasyJWeb默认的是使用普通属性文件。
包含该功能的代码在SVN中,last commit revision为830。 下面是包含其它节点的easyjweb配置文件: <easyjf-web xmlns="http://www.easyjf.com/schema/easyjf/web" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.easyjf.com/schema/easyjf/web http://www.easyjf.com/schema/easyjf/web/easyjf-web-0.0.1.xsd "> <framework-setting> <property name="com.easyjweb.propertiesType">xml</property><!--多国语言属性文件类型--> <property name="com.easyjweb.defaultActionPackages"> com.easyjf.simpleblog.mvc </property><!--设置自加Action扫描的路径,根据你的情况调整--> </framework-setting> </easyjf-web> |
||||||||||||||||||||||||||||||||||||||||||||||
只需要在EasyJWeb的配置文件中添加一个指定多国语言属性文件类型的配置,把该值设置为xml,如下所示:
<property name="com.easyjweb.propertiesType">xml</property><!--多国语言属性文件类型-->
然后就可以在应用中直接使用xml格式的多国语言属性文件了。比如针对hello.ejf,在WEB-INF\applicationResources目录下包含一个hello.xml及hello_en.xml文件,hello.xml的文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>属性文件</comment>
<entry key="hello">你好!</entry>
</properties>
hello_en.xml的文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>属性文件</comment>
<entry key="hello">hi,how are you!</entry>
</properties>
页面中使用多国语言hello:
$lang.get("hello")