Samples > Rule Studio Authoring Extensions > How to Localize the Business Action Language

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

Key features include:

Installing this Sample

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:

  1. Click Help > Software Updates > Manage Configuration.
  2. In the Product Configuration dialog, click the Add an Extension Location link.
  3. In the Browse dialog, select the folder <InstallDir>/studio/samples/eclipse.
  4. If prompted to restart the Eclipse Workbench, click Yes.
  5. Eclipse shuts down and restarts.

To check that the Spanish Business Action Language Sample feature is enabled:

  1. Click Help > Software Updates > Manage Configuration.
  2. In the left pane of the Product Configuration page, expand 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:

  1. Click File > Import.
  2. In the Import Wizard, select ILOG Rule Studio Samples and Tutorials.
  3. Click Next.
  4. On the Sample or Tutorial page, select the sample authoring > carrental_es.
  5. Click Finish.
  6. If one or more files already exist in your workspace, a warning message is displayed indicating the file(s) were not re-imported. Close the message window.
  7. The imported sample project files are displayed in the Rule Explorer. You should see two new projects:
    - carrental-es-xom. A Java project containing an execution model. The class and member names in this XOM are in Spanish.
    - carrental-es-rules. This project contains rules written with the spanish BAL, using a vocabulary on top of the BOM created from the Spanish XOM.

Running this Sample

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:

  1. In the Rule Explorer, expand the rule project carrental-es-rules and open and examine one or more of its rules.
  2. Notice how BAL keywords, expressions, and the options offered in the rule completion menus are all provided in Spanish.
  3. Click Run > Run.
  4. Select the 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:

  1. Open the <InstallDir>/shared/bin/build.xml file.
  2. Add the parameter -nl es to the Eclipse launcher command line.
  3. Restart Eclipse.

To restart Rule Studio in a Spanish locale on Windows:

  1. Click Run > Run.
  2. Select the Run-time Workbench > spanish-rule-studio launch configuration, then click Run.
  3. A new run-time instance of Eclipse is started and is configured with the Spanish locale.
  4. Re-import the carrental_es sample, as described in the Installing this Sample section.

To explore and run the sample in Spanish:

  1. Create and author a new BAL rule in Spanish. For example, recreate an existing rule.
  2. You will see a localized BAL in action.
  3. Save and close the rule.

To create a second BOM entry from the carrental-es-xom XOM:

  1. Right click the bom folder in the carrental-es-rules project and click New >BOM Entry.
  2. In the New BOM Entry dialog, click Create a BOM Entry from a XOM, then click Next.
  3. Click Browse XOM and select the carrental-es-xom XOM.
  4. Select all classes, then click Finish.
  5. Examine the default verbalization for any of the selected classes and notice the effect of a localized verbalizer.

Source Files

To display the source code of the bal_es Eclipse plug-in:

  1. Click File > Import.
  2. In the Import Wizard, select External Plug-ins and Fragments and click Next.
  3. In the Import As section, select the Projects with source folders option and click Next.
  4. In the Plug-ins and Fragments Found list, select the plug-in ilog.rules.studio.samples.bal_es.
  5. Be careful not to select ilog.rules.studio.samples.bal_es.source.
  6. Click Add.
  7. Click Finish.
  8. The source code of the plug-in is imported and appears in the Rule Explorer.
  9. Switch to the Plug-in Development perspective.
  10. In the Package Explorer, navigate to the Java source files in the folder ilog.rules.studio.samples.bal_es > src-bal_es.

The following source files are of interest and described in Highlights:

Highlights

BAL concrete syntax message files must be stored using the ISO-8859-1 encoding:

The Spanish boot vocabulary file must be stored using the UTF-8 encoding:

The IlrSpanishVerbalizer class extends the IlrDefaultVerbalizer general-purpose verbalizer 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):

Related Concepts

Vocabulary
Vocabulary Elements

Related Tasks

Localizing JRules

Related Reference

Business Action Language

Related Samples and Tutorials

Import Samples and Tutorials Wizard