Professional > Table scripting > Working with metadata > Working with languages
 
Working with languages
Sample Script Files: WorkingWithLanguages.mrs, JapaneseTables.mrs
These example scripts are based on the Museum sample data set. See Running the sample table scripts for information on running the example scripts.
If the metadata has been translated, you can choose to create the tables in any of the languages that are available. For example, the metadata in the Museum XML sample (museum.mdd) has been translated into Spanish and Japanese, so you can easily create tables in either of these languages.
You select the language to be used by setting the Document.Language property to the three-character code of the language you want to use. For example, to set the language to Spanish:
TableDoc.Language = "ESN"
Element list syntax provides examples of setting up custom element labels for use in the current language and in more than one language. The following script creates two tables: the first uses the default labels defined in the metadata and the second uses custom element labels that are defined in two languages (English and Spanish):
With TableDoc.Tables
.AddNew("Table1", "age * gender", "Edad por Género")
.AddNew("Table2", "interest{Dinosaurs ENU:'Extinct reptiles' " + _
"ESN:'Reptiles extintos', Whales ENU:'Large marine mammals' " + _
"ESN:'Mamíferos marinos grandes'} * gender", _
"La galería más interesante por Género")
End With
You can also define custom labels for the variables. For example, the following defines a custom label in Spanish for the interest variable in the second table:
TableDoc.Tables.Table2.Side.Interest.Label["ESN"] = "La galería más interesante"
This example makes use of the dynamic property expansion feature of mrScriptBasic, which enables you to access the Interest item as if it were a property of the Side axis. Note that you cannot use this feature with variables that have a period (.) in their name (for example, variables that are inside a grid or loop). For these variables you would specify the custom label like this:
TableDoc.Tables.Table2.Side.SubAxes["Interest"].Label["ESN"] = "La galería más interesante"
Note that if you do not specify the language code, the custom label will apply to the currently selected language only.
When you are working with foreign languages, make sure that you save your script file using the Unicode or UTF-8 text format option and not the ANSI option.
Here is the table that uses the default Spanish texts:
Table of Age by Gender with default Spanish labels
Here is the table that uses the Spanish texts we defined in the script:
Table of Interest by Gender with customized Spanish labels
The default label (Base) that UNICOM Intelligence Reporter creates for the autobase element is suitable for use in Spanish. However, in some languages you may want to specify a translation. The following example sets the language to Japanese, sets up some tables and changes the text on the autobase elements:
TableDoc.Language = "JPN"
With TableDoc.Tables
  .AddNew("Table1", "age * gender")
  .Table1.Side.Age.Elements.Base.Label = "<Japanese text>"
  .Table1.Top.Gender.Elements.Base.Label = "<Japanese text>"
  .AddNew("Table2", "interest{Dinosaurs, Whales} * gender")
  .Table2.Side.Interest.Elements.Base.Label = "<Japanese text>"
  .Table2.Top.Gender.Elements.Base.Label = "<Japanese text>"
End With
Here is the second table:
Table of Age by Gender with labels in Japanese
See also
Working with metadata