Localizing Brightspot

You can customize Brightspot widgets and content edit forms so that users see the GUI in their preferred language. Localizing Brightspot is similar to that for other Java-based web applications.

Widgets

  1. Open your Brightspot project in a file manager.

  2. Clone or download the Brightspot CMS repository from https://github.com/perfectsense/brightspot-cms.git.

  3. From the cloned repository, recursively copy all files *Default_xx.properties in the directory db/src/main/resources to your Brightspot project directory src/main/ (so that the directory resources/ appears under main/).

    Note

    In addition to the English-language property files *Default_en.properties, the cloned repository may also provide property files for other languages such as Spanish (*Default_es.properties). If your target language is included, go to step 6.

  4. If Brightspot does not provide the property files for your target language, rename each *Default_en.properties to *Override_xx.properties.

    • The literal Override is mandatory.
    • The two letters before .properties must be a language code that Java recognizes. For a list of two-letter language codes, see Codes for the Representation of Names of Languages.
    • Example: mv BulkUploadWidgetDefault_en.properties BulkUploadWidgetOverride_fr.properties
  5. For each of the resource files, provide localized strings.

    # Localization for the Upload widget
    
    title=Transfert Groupé
    
    message.noTypes=Il n'y a pas de types de contenu qui peuvent être transfert groupé.
    
  6. Rebuild your Brightspot project.

Users who change their Locale setting in Admin > Users & Roles see the localized text in the Brightspot GUI.

../../../_images/localized-bulk-upload-fr.png

Content Edit Forms

You can localize the field and tab labels in content edit forms. The following screenshots show the GUI result of localizing an Article Model class into Spanish.

English Spanish
../../../_images/localized-content-edit-form-en.png ../../../_images/localized-content-edit-form-es.png

Localization of content edit forms is achieved with properties files, where keys for fields and tabs are set with language-specific strings.

To create a properties file for a Model:

  1. Change to or create the resources/ directory for your Brightspot project. This directory is in the standard position for Maven projects, src/main/resources/, although your Brightspot project may have a different resources/ directory if your project includes themes.

  2. Change to or create the subdirectory corresponding to the required Model. For example, if you are localizing the content edit form for articles, change to or create the subdirectory article/.

  3. Create the file <ContentType>Override.properties_xx. For example, the file ArticleOverride_es.properties localizes the article Model into Spanish.

  4. In the properties file, add lines that specify the localized names of fields and tabs, using the following forms: field.<fieldname>=<localname> and tab.<tabname>=<localname>.

    The following example shows localization of an Article Model into Spanish.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    # Localization for Article Content Edit Form
    
    field.headline=Titular
    field.leadImage=Imagen de Plomo
    field.body=Texto del Cuerpo
    
    tab.Main=Principal
    tab.Overrides=Anulaciones
    tab.Push\ Notification=Notificación
    

    In the previous snippet—

    • Lines 3–5 localize names of the fields defined in the Article Model class.

    • Lines 7–9 localize names of the default tabs that Brightspot provides for content edit forms. Note that if a tab name is more than one word, such as “Push Notification”, the spaces between words need to be escaped.

      If you add custom tabs to a Model via @ToolUi.Tab, they, too, can be localized by adding their names to the properties file.

  5. Reload or rebuild your Brightspot project.

Users who change their Locale setting in Admin > Users & Roles see the localized text in the Article content edit form.