Creating a Multi-Locale Application Using LNGPREP

How to:

In this example, you will use the LNGPREP file to create language files that you can translate, allowing you to set a parameter to change the language of a procedure on-demand at run-time. This procedure uses the WebFOCUS Reporting Server Console to create the .cfg and .lng configuration files, and WebFOCUS App Studio to create the parameterized report. You will follow the following steps:

Procedure: How to Create Multi-Locale Master Files

You can use the LNGPREP function in a procedure to create localization files for any synonym on your Reporting Server. This function references a .cfg language input file that lists the languages that you wish to localize for. As a result, this language input file must be created first.
  1. In the Web Console, locate the ggsales synonym. If you do not have it already, you can generate it.
    1. The ggsales synonym is included in the Legacy Sample Tables and Files. To create these files on your environment, in the Applications tab of the Web Console, right click the application folder that you wish to use (for example, you could use a new application folder called nls), point to New, and click Tutorials.

      The Create Tutorial Framework page opens.

    2. From the Tutorial drop-down menu, select Create Legacy Sample Tables and Files and click Create.

      The Select an Option dialog box opens. Click OK.

      A number of sample synonyms are created, including ggsales.

  2. Create the language input file. This is a .cfg file that contains a list of all of the languages that you want to localize your synonym for. For this example, the language input file will specify that localizations are being created for French, Spanish, and Portuguese.
    1. Right-click the application folder, point to New, and click Text File.

      The text editor opens in the Web Console.

    2. The .cfg file is formatted with one language per line, as three-character codes, with no punctuation. To specify French, Spanish, and Portuguese as the localized languages, type the following in the text file:
      fre
      spa
      por

      A table containing language codes can be found in Specify Multilingual DESCRIPTION and TITLE Attributes.

      Note: English (eng) does not need to be specified. It is used as the base value for LNGPREP, even if the original file is not in English. If you are localizing a Master File from a foreign language to English, you must use a more specific English code, like uke for British English or ame for American English, to specify an English localization.

    3. Once you have entered the languages you are localizing for, click Save As in the text editor. Give the file a name and type cfg in the Extension text box to save the file as a .cfg file.
  3. Create the .lng translation files. These files will be translated to provide localized column and table names.
    1. In the navigation pane, right-click the ggsales synonym, point to Metadata Management, and click Prepare Translation Files.

      The Set Translation Files page opens.

    2. Enter or browse for the application folder in which to save the translation files. This folder can be within a hierarchy, such as nls/ggsales.
    3. Set a prefix that will be included in the name of each translation file. For example, if you set the prefix to ggsales_, and have fre, spa, and por in the language input file, then the translation files ggsales_eng.lng, ggsales_fre.lng, ggsales_spa.lng, and ggsales_por.lng will be generated.

      As noted previously, prefixeng.lng is generated automatically and serves as the base translation file containing the column and table names specified in the Master File, even if those names are not in English. You would use the prefixame.lng or prefixuke.lng file as the English translation file.

    4. Specify the .cfg language input file by entering or browsing for it in the Languages File field.
    5. Click OK.

      You are informed that the translation files have been created in the specified folder.

  4. Refresh the navigation pane and open each translation file, except for the base prefix_eng translation file, to translate it. Translate each title and description in the translation file. Do not modify the numbers in the file.

    Each translation file matches a number with each title and description in the Master File. The text next to each number must represent the same fields and segments in each translation file for the translations to be correct.

    You can translate the values in the translation files for ggsales, as follows:

    ggsales_eng.mas

    (Base Values)

    ggsales_fra.mas

    ggsales_spa.mas

    ggsales_por.mas

    Legacy Metadata Sample: Gotham Grinds - GGSALES

    Exemple Métadonnées héritées: Gotham Grinds - GGSALES

    Ejemplo metadatos heredados: Gotham Grinds - GGSALES

    Exemplo de Metadados de Legado: Gotham Grinds - GGSALES

    Sequence#

    # de séquence

    n.° de secuencia

    Sequência#

    Sequence number in database

    Nombre de séquence dans Base de données

    Número de secuencia en base de datos

    Número de sequência no banco de dados

    Category

    Catégorie

    Categoría

    Categoria

    Product category

    Produit Catégorie

    Categoría de Producto

    Produto Categoria

    Product ID

    ID de produit

    ID de Producto

    ID do produto

    Product Identification code (for sale)

    Code d’identification du produit (en vente)

    Código de identificación del producto (para la venta)

    Código de identificação do produto (para vendas)

    Product

    Produit

    Producto

    Produto

    Product name

    Nom de Produit

    Nombre de Producto

    Nome do produto

    Region

    Région

    Región

    Região

    Region Code

    Code de région

    Código de región

    Código da região

    State

    État

    Estado

    Estado

    City

    Ville

    Ciudad

    Cidade

    Store ID

    ID de magasin

    ID de tienda

    ID da loja

    Store identification code (for sale)

    Code d’identification du magasin (en vente)

    Código de identificación de la tienda (para la venta)

    Código de identificação da loja (para vendas)

    Date

    Date

    Fecha

    Data

    Date of sales report

    Date du rapport de vente

    Fecha del informe de venta

    Relatório de data de vendas

    Unit Sales

    Ventes en unités

    Ventas de unidades

    Vendas por unidade

    Number of units sold

    Nombre d’unités vendues

    Número de unidades vendidas

    Número de unidades vendidas

    Dollar Sales

    Ventes en dollars

    Ventas en dólares

    Vendas em dólares

    Total dollar amount of reported sales

    Montant total des ventes en dollars

    Volumen total de ventas en dólares

    Quantidade total em dólares de vendas relatadas

    Budget Units

    Unités budgétaires

    Unidades presupuestadas

    Unidades de orçamento

    Number of units budgeted

    Nombre d’unités budgétées

    Número de unidades presupuestado

    Número de unidades orçadas

    Budget Dollars

    Budget en dollars

    Presupuesto en dólares

    Orçamento em dólares

    Total sales quota in dollars

    Quota total des ventes en dollars

    Cuota total de ventas en dólares

    Cota total de vendas em dólares

    Once you have translated each translation file as described, save each one.
Once complete, the Master File should have the TRANS_FILE parameter automatically added to it. To check, right-click the Master File and click Edit as Text. The parameter should appear on the first line, listing the location and prefix of the translation files.

Procedure: How to Create a Procedure for Multi-Locale Reporting

Once your data has been localized, it is easy to use in a procedure, such as a report.

  1. In App Studio, create a new report based on the ggsales synonym.
    1. In the Environments Tree panel, right-click the folder where you want to create the report, point to New, and click Report.
    2. In the Select Data Source dialog box, click the application folder containing the ggsales synonym and open ggsales.mas.

      The Report canvas opens.

  2. Add the desired fields to your report, and save and close it.
  3. Next, create parameters to set the language, date format, and decimal notation of the report based on user selection in the Responsive Autoprompt facility.

    These parameters are created as the values for SET commands. You can create a SET command by typing it above the TABLE FILE request in your report.

    For more information on SET commands, see the Developing Reporting Applications manual.

    Note that all set commands should be kept to one line. Any line breaks in this section are due to size constraints on this page.

    1. In the Environments Tree panel, right-click your newly created report and click Open in Text Editor.
    2. At the top of the report, create a simple parameter for LANG that uses a single-select list.

      LANG sets the language of the report. For more information, see Activate the Use of a Language.

      The syntax for creating a single-select static list for LANG is as follows:

      SET LANG = '&variable.(<displaylang1,codelang1>,<displaylang2,codelang2>, ... ).Title.'

      where:

      &variable

      Is the name of the variable, including the ampersand (&), for which you are supplying a list of values.

      displaylang1

      Is the display value for the first language that will display in the Responsive Autoprompt drop-down menu.

      codelang1

      Is the three-character language code for the first language that will display in the Responsive Autoprompt drop-down menu. This value is also found in the title of the translation file.

      displaylang2

      Is the display value for the first language that will display in the Responsive Autoprompt drop-down menu.

      codelang2

      Is the three-character language code for the first language that will display in the Responsive Autoprompt drop-down menu. This value is also found in the title of the translation file.

      ...

      The display name and language code values for any other options in the drop-down menu, separated by a comma and wrapped in angle brackets.

      Title

      Is the title that will display above the drop-down menu.

      For this example, you can use the following command:

      SET LANG = '&Lang.(<English,eng>,<French,fre>,<Spanish,spa>,<Portuguese,por>)
      .Language.'
    3. Create another simple parameter for the date format, if you are using a date field in your report. The date format is set using the DATE_ORDER command.

      The syntax to create a simple parameter with a single-select list for DATE_ORDER is as follows:

      SET DATE_ORDER = '&variable.(DMY,MDY,YMD).Title.'

      where:

      &variable

      Is the name of the variable, including the ampersand (&), for which you are supplying a list of values.

      DMY,MDY,YMD

      Are the available options to use as values for DATE_ORDER. DMY represents day/month/year, MDY represents month/day/year, and YMD represents year/month/day.

      Title

      Is the title that will display above the drop-down menu.

      Note that display values are not being specified. In this case, the possible DATE_ORDER values are displayed literally in the Responsive Autoprompting drop-down menu.

      For this example, you can use the following command:
      SET DATE_ORDER = '&Date_order.(DMY,MDY,YMD).Date Order.'
    4. Create a simple parameter for decimal notation, which determines the formatting for decimals and large numbers. Decimal notation is set by the CDN command. For more information, see Punctuating Large Numbers.

      The syntax to create a simple parameter with a single-select list for CDN is as follows:

      SET CDN = '&variable.(<displayoff,OFF>,<displayon,ON>,<displayspace,SPACE>,
      <displayquote,QUOTE>,<displayquotep,QUOTEP>).Title.'

      where:

      &variable

      Is the name of the variable, including the ampersand (&), for which you are supplying a list of values.

      displayoff

      Is the value to display in the menu for when CDN is set to OFF.

      OFF

      Is the default format. Alternatively, COMMAS_DOT serves the same function. Commas are used as thousands separators and a period is used as the decimal point. For example, 123,456.78.

      displayon

      Is the value to display in the menu for when CDN is set to ON.

      ON

      Turns CDN on. Alternatively, DOTS_COMMA serves the same function. Periods are used as thousands separators and a comma is used as the decimal point. For example, 123.456,78.

      displayspace

      Is the value to display in the menu for when CDN is set to SPACE.

      SPACE

      Sets CDN to SPACE. Alternatively, SPACES_COMMA serves the same function. Spaces are used as thousands separators and a comma is used as the decimal point. For example, 123 456,78.

      displayquote

      Is the value to display in the menu for when CDN is set to QUOTE.

      QUOTE

      Sets CDN to QUOTE. Alternatively, QUOTES_COMMA serves the same function. Quotes are used as thousands separators and a comma is used as the decimal point. For example, 123'456,78.

      displayquotep

      Is the value to display in the menu for when CDN is set to QUOTEP.

      QUOTEP

      Sets CDN to QUOTEP. Alternatively, QUOTES_DOT serves the same function. Quotes are used as thousands separators and a period is used as the decimal point. For example, 123'456.78.

      Title

      Is the title to show above the drop-down menu in Responsive Autoprompt.

      For this example, you can use the following command:

      SET CDN = '&CDN.(<Off,OFF>,<On,ON>,<Spaces with Comma,SPACE>,<Quotes with Comma,QUOTE>,<Quotes with Dot,QUOTEP>).Decimal Notation.'
      
    The following is an example of a full report.
    SET LANG = '&Lang.(<English,eng>,<Français,fre>,<Español,spa>,<Português,por>).Language.'
    SET DATE_ORDER = '&Date_order.(DMY,MDY,YMD).Date Order.'
    SET CDN = '&CDN.(<Off,OFF>,<On,ON>,<Spaces with Comma,SPACE>,<Quotes with Comma,QUOTE>,<Quotes with Dot,QUOTEP>).Decimal Notation.'
    
    TABLE FILE nls/GGSALES
    SUM
         GGSALES.SALES01.BUDUNITS
         GGSALES.SALES01.UNITS
         GGSALES.SALES01.DOLLARS
    BY  GGSALES.SALES01.REGION
    BY  GGSALES.SALES01.ST
    BY  GGSALES.SALES01.CITY
    ON TABLE SET PAGE-NUM NOLEAD
    ON TABLE SET ASNAMES ON
    ON TABLE NOTOTAL
    ON TABLE PCHOLD FORMAT HTML
    ON TABLE SET HTMLEMBEDIMG ON
    ON TABLE SET HTMLCSS ON
    ON TABLE SET STYLE *
         INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/warm.sty,
    $
    ENDSTYLE
    END
    
  4. Save and run the report.

    You are prompted to select a language, date order, and decimal notation from the Responsive Autoprompt interface.

    Select your options and click the run button. The report loads to match your specifications, as shown in the following image.


    Report showing language selection in Responsive Autoprompt

WebFOCUS

Feedback