Mondrian国际化

Mondrian国际化
在Schema里的Dimension、Level、Measure标签都有一个caption属性,在shecma里有个measuresCaption属性,Hierarchy里有个allMemberCaption属性都是国际化显示用的。格式为:caption="%{}"
通过以下几个步骤便可实现国际化         
一、修改Schema如下
.
        
< Dimension  foreignKey ="TIME_ID"  name ="TIME" >
            
< Hierarchy  hasAll ="true"  allMemberName ="All time"  primaryKey ="TIME_ID"  allMemberCaption ="%{compensation.dimension.time.allmember.caption}" >
                
< Table  name ="TIME_TO_MONTH" >
                
</ Table >
                
< Level  name ="YEAR"  table ="TIME_TO_MONTH"  column ="YEAR"  type ="String"  uniqueMembers ="false"  levelType ="Regular"  hideMemberIf ="Never" >
                
</ Level >
                
< Level  name ="QUARTER"  table ="TIME_TO_MONTH"  column ="QUARTER"  type ="String"  uniqueMembers ="false"  levelType ="Regular"  hideMemberIf ="Never" >
                
</ Level >
                
< Level  name ="MONTH"  table ="TIME_TO_MONTH"  column ="MONTH"  type ="String"  uniqueMembers ="false"  levelType ="Regular"  hideMemberIf ="Never" >
                
</ Level >
            
</ Hierarchy >
        
</ Dimension >
        
< Measure  name ="UOT1"  column ="UOT1"  caption ="%{compension.measure.uot1.caption}"  datatype ="Numeric"  formatString ="#,##0.###"  aggregator ="sum" >
        
</ Measure >
二、在WEB Application 的classes里创建对应的国际化文件,命名如下locale_zh_CN.properties
compensation.dimension.time.allmember.caption=\u5168\u90e8\u65f6\u95f4
compensation.dimension.position.allmember.caption=\u5168\u90e8\u8d44\u4f4d
compension.measure.uot1.caption=1.5\u500d\u52a0\u73ed\u65f6\u6570
compension.measure.uot2.caption=2\u500d\u52a0\u73ed\u65f6\u6570
compension.measure.uot3.caption=3\u500d\u52a0\u73ed\u65f6\u6570
三、在classes里添加mondrian.properties文件(默认是在WEB-INF下),并添加下面两个属性
Locale:用于指定要使用的语言
mondrian.rolap.localePropFile:国际化文件绝对路径
Locale=zh_CN
mondrian.rolap.localePropFile=D:\\JAVA\\Tomcat5.5\\webapps\\mondrian\\WEB-INF\\classes\\locale.properties
四、在显示的页面上的<jp>标签里添加dynLocale="zh_CN" dynResolver="mondrian.i18n.LocalizingDynamicSchemaProcessor"
< jp:mondrianQuery  id ="query01"  jdbcDriver ="oracle.jdbc.OracleDriver"  dynLocale ="zh_CN"  dynResolver ="mondrian.i18n.LocalizingDynamicSchemaProcessor"  jdbcUrl ="jdbc:oracle:thin:@*.*.*.*:1521:wiptest"  jdbcUser ="oee"  jdbcPassword ="oee"  catalogUri ="/WEB-INF/queries/Compensation.xml" >
select {[Measures].[UOT1],[Measures].[UOT2],[Measures].[UOT3]} ON columns,
{([TIME].[All time],[POSITION].[All position], [DEPT]) } on rows
FROM [Compensation]
</ jp:mondrianQuery >
关于国际化功能实现相关代码在LocalizingDynamicSchemaProcessor和MondrianProperties两个类里。

你可能感兴趣的:(Mondrian国际化)