| Samples > Rule Studio Authoring Extensions > How to Localize the Business Action Language |
How to Localize the Business Action Language |
PREVIOUS NEXT |
This sample shows how to localize the Business Action Language (BAL) to enable you to write rules and decision tables in the localized language. To localize the BAL, you must:
A verbalizer builds human-readable terms and phrases for the concept and fact types of the vocabulary. In particular, the verbalizer proposes default values for the plural forms of a term, assembles the articles and terms to build default phrases for action and navigation fact types.
Key features include:
IlrVerbalizer interface, IlrTermBuilder, IlrArticleBuilder and IlrPluralBuilder interfaces.
This sample extends the Rule Studio API. The required sample plug-ins are delivered as pre-deployed. If you have not already done so, you must install the samples extension site in Eclipse before running this sample.
This sample uses Spanish as the localized language. This is for illustration only, and is not officially supported.
To install the plug-in samples extension site:
<InstallDir>/studio/samples/eclipse.
To check that the Spanish Business Action Language Sample feature is enabled:
C:\ILOG\JRules\studio\samples\eclipse and check that Spanish Business Action Language Sample 1.0.0. is listed.
To import the carrental_es sample:
ILOG Rule Studio Samples and Tutorials.
authoring > carrental_es.
You will start by exploring and running the sample, then restarting Rule Studio in a Spanish locale. You will then explore and run the sample in Spanish, then create a second BOM entry from the XOM.
To explore and run the sample:
carrental-es-rules and open and examine one or more of its rules.
carrental_es launch configuration, then click Run.
A simple ilrmain function runs the rules for a simulated input parameter. The Spanish rules are translated into correct IRL syntax, independently of the locale in which the rules are executed.
To restart Rule Studio in a Spanish locale on UNIX:
<InstallDir>/shared/bin/build.xml file.
-nl es to the Eclipse launcher command line.
To restart Rule Studio in a Spanish locale on Windows:
Run-time Workbench > spanish-rule-studio launch configuration, then click Run.
carrental_es sample, as described in the Installing this Sample section.
To explore and run the sample in Spanish:
To create a second BOM entry from the carrental-es-xom XOM:
bom folder in the carrental-es-rules project and click New >BOM Entry.
carrental-es-xom XOM.
To display the source code of the bal_es Eclipse plug-in:
External Plug-ins and Fragments and click Next.
ilog.rules.studio.samples.bal_es.
ilog.rules.studio.samples.bal_es > src-bal_es.
The following source files are of interest and described in Highlights:
BAL concrete syntax message files must be stored using the ISO-8859-1 encoding:
bal_es.properties: Translations for main BAL keywords: "definitions", "if", "then", "else", and so on
dt_es.properties: Translations for decision table specific keywords and definitions.
balexpr_es.properties: Translations for BAL expressions such as "there is/are ...", "the number of", "all of the following conditions are true", "any of ..."
expr_es.properties: Translations for expressions such as "where", "in/from",
brl_es.properties: Localized regular expressions to parse and render numbers, dates and time literal values, and translations for warnings and error messages
bindings_es.properties: Translations for the expressions used to write definitions
actions_es.properties: Translations for the expressions used to write actions
The Spanish boot vocabulary file must be stored using the UTF-8 encoding:
boot_es.voc: Translations for basic terms, fact types and operators: boolean, numbers, strings, dates, times
The IlrSpanishVerbalizer class extends the IlrDefaultVerbalizer general-purpose verbalizer class:
verbalize method concatenates the appropriate article (depending on the verbalization context) with the term label (possibly using a plural form)
getSupportedGenders and getDefaultGender methods declare the possible and default genders used in a language, respectively. In Spanish, for example, nouns are either masculine or feminine, and the default value is masculine.
getGetterTemplate / getSetterTemplate to access a regular member, getPredicateGetterTemplate / getPredicateSetterTemplate to access a boolean member, getCollectionAddTemplate / getCollectionRemoveTemplate to modify a collection
IlrSpanishUtil class.
The IlrSpanishArticleBuilder class returns articles for all possible genders, in both singular and plural forms.
The IlrSpanishTermBuilder class creates a term from a string source, using the IlrSpanishUtil class to try to adapt the default label to Spanish specific conventions, and guess the gender of the term.
The IlrSpanishPluralBuilder class also uses the IlrSpanishUtil class to return the plural form of a term or a fact type.
The IlrSpanishUtil class deals with a certain number of idiomatic rules and conventions (it can be extended further to cover more rules):
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |