Implementer training - template localization

Funnelback natively handles documents and queries in non-English languages and in non-Latin character sets. Funnelback’s built-in Freemarker templates can also be configured to support localization. This can be useful when providing a search interface designed to target several regions or languages.

Template localization allows the definition of one or more alternate sets of labels for use within the Funnelback templates.

Additional configuration can be created defining the label text for different languages - and the templates configured to use the labels from the appropriate localization file.

The localization is selected by providing an additional CGI parameter that defines the translation file to apply to the template.

Tutorial: Create a simple localization file

In this exercise an English (simplified) localization file will be created that defines some less technical labels for some headings used on the advanced search form.

  1. Log in to the search dashboard where you are doing your training.

    See: Training - search dashboard access information if you’re not sure how to access the training. Ignore this step if you’re treating this as a non-interactive tutorial.
  2. Select the Foodista search results page.

  3. Create a new localization file from the file manager screen. (Select manage results page configuration files from the customize panel, then create a new ui.*.cfg file, entering en_SI as the filename, when prompted.

    exercise create a simple localization file 01
    exercise create a simple localization file 02
  4. Define two alternate labels - add the following to the file then click the save and publish button:

    metadata=Properties
    origin=Position
    exercise create a simple localization file 03
  5. The default Funnelback search form hardcodes the labels in the template. Edit the default template and update the hardcoded labels to translation variables, defining a fallback to a default value. Locate the Metadata and Origin text in labels in the advanced search form (lines approx. 184 and approx. 268) and replace these with ${response.translations.metadata!"Metadata"} and ${response.translations.origin!"Origin"}. Click the save and publish button after making your changes.

    exercise create a simple localization file 04
  6. View the advanced search form - run a query for eggs, then view the advanced search form by selecting advanced search from the menu underneath the cog.

    exercise create a simple localization file 05
  7. Observe the metadata heading and origin items are displaying the default values. This is because you’re not applying your translations.

    exercise create a simple localization file 06
  8. Modify the URL to specify the language by adding &lang.ui=en_SI to the URL. Observe that the labels for metadata and origin update to properties and position, matching what you defined in the localization file. ]

    exercise create a simple localization file 07