You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

Localization

Any output in Structr can be localized by using the built-in function localize(). Using localize() tells Structr to display a localized value of the text in name, if a matching localization is found in the database, or the text itself, if no matching localization was found.

Requested Parameters

There are two parameters to define the requested localization: name and the optional domain.

The requested locale is determined from different potential sources, see locale. It’s basically a String value consisting of a mandatory language part and an optional country part, separated by an underscore (_).

Stored Parameters

The built-in type Localization serves as source for the localize() function. There are four attributes which define a stored localization element:

  • name
    The key which is used to look up the localization
  • domain
    The localization domain. This serves as a means of distinguishing between otherwise duplicate names.
    Because of the way localize() returns localizations the domain-less localization can be used as a default localization for a certain name.
  • locale
    The locale for which the localization applies.
  • localizedName
    The localized string. This is the return value of the localize() function in case of a match.
Matching Requested with Stored Parameters

The following rules determine the return value of the localize() function:

  1. Exact match
    The requested locale String, the name and the domain attributes match exactly.

  2. No requested domain
    The requested locale and name match exactly, but there is no requested domain. In this case, only localizations without domain are taken into account. If more than one localization item is found, the first one is returned.

  3. With requested domain, but only non-domain localizations are stored
    Given exactly matching locale and name attribute, if a domain is requested, but there are no localization items stored with a matching domain attribute, the first localization without a domain, but matching locale and name is returned.

If the localization items are stored with a locale String that has the country part only, the only the language part of any requested locale is taken into account.

Structr has a concept of localized strings. The built-in type Localization serves as source for the localize() function.

An object of type localization has four defining attributes:

  • name
    The key which is used to look up the localization
  • domain
    The localization domain. This serves as a means of distinguishing between otherwise duplicate names.
    Because of the way localize() returns localizations the domain-less localization can be used as a default localization for a certain name.
  • locale
    The locale for which the localization applies.
  • localizedName
    The localized string

  • imported
    • This flag has no effect on the localization itself. It merely serves as an indicator wether or not the localization entry has been imported. This can happen when Structr is used to replace an existing system.

Examples

  1. Simple example without domain

    name domain locale localizedName
    helloWorld en Hello world
    helloWorld de Hallo Welt
    helloWorld fr Bonjour monde
    helloWorld es Hola mundo
  2. Example where a domain is used (but the locale is rather meaningless)

    name domain locale localizedName
    USD en_EN Dollar
    USD symbol en_EN $
    GBP en_EN Pound
    GBP symbol en_EN £
    EUR en_EN Euro
    EUR symbol en_EN
  3. Simple example with country code

    name domain locale localizedName
    hello de_DE Hallo
    hello de_AT Servus
    hello de_CH Grüezi

Search results for "Localization"

Localization

application.localization.logmissing If enabled, missing requested localizations are logged.
application.localization.usefallbacklocale Turns on usage of fallback locale if for the current locale no localization is found
application.localization.fallbacklocale The default locale used, if no localization is found and using a fallback is active.

Localizations

The Localizations flyout allows you to load all localizations for the given locale on the current page (including the UUID of the details object which is also used for the preview).

A localization is an expression that is included in the content of a page or any other textual element in the following form:

The retrieval process works just as rendering the page. If you request the locale en_US you might get localizations for en as a fallback if no exact match is found. If no localization could be found, an empty input field is rendered where you can quickly create the missing localization.

Deployment Format

folder / filedescription
componentsContains the shared components of the pages editor of Structr.
filesContains all files out of Sturctr’s virtual filesystem. Folders and files in the virtual filesystem are not being exported by default. If you want to include a folder or file into the export you have to set the flag includeInFrontendExport on each file or folder. Each file or folder will inherit this flag from its parent folder.
mail-templatesContains the mail-templates.
modulesContains the application configuration and definition of additional modules of Structr e.g. the flow engine.
pagesContains the created pages in the pages editor of Structr.
schemaContains the schema definition and code entered in the schema and code section of the Structr UI.
securityContains the resource access grants defined in the security section of the Structr UI.
templatesContains all template elements of the pages editor of Structr.
application-configuration-data.jsonContains the configured schema layouts of Structr’s schema editor.
components.jsonContains the settings e.g. visiblity flags, contentType or uuid for each file in the components folder of the export.
deploy.confContains information about the Structr system that created the export of the application.
files.jsonContains the settings e.g. visiblity flags, contentType or uuid for each file in the files folder of the export.
localizations.jsonContains the localizations that where created in the localizations section of the Structr UI and that can be used in server side scripting with the localize() function of Structr.
mail-templates.jsonContains the settings e.g. visiblity flags, locale or uuid for each file in the mail-templates folder of the export.
pages.jsonContains the settings e.g. visiblity flags, contentType or uuid for each file in the pages folder of the export.
pre-deploy.confScript that is run before deployment import. Use this to create users who are granted access to nodes in the export files.
post-deploy.confScript that is run after deployment import. Can be used to start any tasks which are necessary after import.
sites.jsonContains sites that are configured in the pages section of the Structr UI.
templates.jsonContains the settings e.g. visiblity flags, contentType or uuid for each file in the templates folder of the export.
widget.jsonContains the widgets that were created in the pages section of the Structr UI.