Drupal Design Multilingual - NCIOCPL/cgov-digital-platform GitHub Wiki

Background

Cancer.gov has both English and Spanish language user interfaces and content.

Required Core Modules

There are multiple modules that provide the functionality to support this. Additionally, there are many issues that affect multi-lingual sites.

  • Language (language) - While the core library provides much of the language system support, the language module allows for creation of multiple languages. (So language.entity.es.yml is a ConfigurableLanguage entity provided by the language module)

  • Interface Translation (locale) - This provides:

    • The ability to manage the string translations used through the t() and {% trans %} functions.
    • Importing of .po files
    • "Interface Language" filtering for views, blocks and many other things.
      • e.g. What is the language of the current URL, or Admin screen
  • Content Translation (content_translation) - This provides:

    • users to translate content items.
    • "Content Language" filtering for views, blocks and many other things.
      • e.g. what is the language of the node/media I am viewing?
  • Configuration Translation (config_translation) - Provides translations for configurations such as date formats, views titles, *

  • Interface Translation (locale) needed to be enabled to install a site profile with more than 1 language, or a single non-English language.

  • Locale has some quirks when it comes to content vs UI

    • By default the UI & Content are detected the same way. Thanks to Issue 2189267 that is no longer the case.
      • Set the interface detection to "Account administration pages language setting." and you can choose in your profile what language.
      • However, you MUST customize the Content Language Detection and select "URL" with "espanol" as the base for Spanish
        • Otherwise when you edit content it will be in the current language.
  • Something in the site install process reverts our choice of wanting language-url enabled for content translations. The config has it, and a drush cex-modify config-drush cim yields the proper selection.

Translations

A translation pack for each non-(US)English language will be downloaded (localize.drupal.org/download) to sites/default/files/translations. These must be kept up to date, which is a TBD thing. There are potentially some security considerations when allowing Drupal to automatically download.

Additionally, when using locale, many configuration files will be duplicated in a language/<2CHAR> folder. I am going to attempt to NOT include these and see what happens. It may be possible though that we must translate all of our configurations. (e.g. the workflow state names) This was an automated process when the locale was added - I would wonder if updates (through hooks or new configs) would update the system's configuration state or not.

Configs

  • language.negotiation.yml - Settings for Language detection.
  • language.types.yml - Defines which language detection methods will be used. (and their priority)
⚠️ **GitHub.com Fallback** ⚠️