Details
-
Type:
New Feature
-
Status: Open
-
Severity:
Medium
-
Resolution: Unresolved
-
Affects Version/s: 3.5.0 GA (4.8.0 GA Suite Release), 4.0.0 (5.1.0 GA Suite Release)
-
Fix Version/s: Backlog
-
Component/s: None
-
Labels:None
-
Notice:
Description
As an end user, I would like captions of members of a particular level to appear in my own language. As a schema designer, I don't want to have to create a schema for each locale. As a DBA, I don't want each schema to have its own cache.
Currently the best practice is as described in http://forums.pentaho.com/archive/index.php/t-47453.html (see the post at 8-17 4:21am). The basic idea is to define a column for each locale. Suppose you want to support locales 'en', 'fr_CA', 'es'.
1. In the Product table create and populate the columns
product_caption_en
product_caption_fr_CA
product_caption_es
2. Define the level like this:
<Level name="Product Name" table="product" column="product_name"
caption="product_name_%
uniqueMembers="true"/>
3. Create the connection using the LocalizingDynamicSchemaProcessor. It will substitute %{locale}
.
I would like to improve this in say mondrian-4.1. In mondrian-4 schema syntax, we'd add a localePattern to the Caption element:
<Attribute name='Product Name' table='product' hasHierarchy='false'
keyColumn='product_id' nameColumn='product_name'>
<Caption localePattern='product_name_%
</Attribute>
"localePattern" is the same as "name", but it is scanned for %{locale}
and there is an escape syntax (TBD) for % if for some bizarre reason you want % in your column name. It is an error if the table does not contain a column for each locale supported by the schema.
Compare to the usual:
<Attribute name='Product Name' table='product' hasHierarchy='false'
keyColumn='product_id' nameColumn='product_name'/>
where captionColumn defaults to nameColumn, i.e. product_name.
No DynamicSchemaProcessor is required.
To declare which locales a schema supports, add a "locales" attribute to the Schema element:
<Schema name='Sales' metamodelVersion='4.1' locales='en,fr,fr_CA,es'>
When loading members, Mondrian loads the captions for all languages. Thus a single schema can serve all languages. You can get the new language by calling OlapConnection.setLocale(Locale). Then Member.getCaption() would magically return the right value for the connection's locale.