Adding a language to Drupal core

Last updated on
22 November 2023

Overview

The process for adding a language to Drupal core is:

  1. Gather essential language information.
  2. Create a translation team at localize.drupal.org.
  3. Modify Drupal core to know about the language.

Gather essential language information

Before you can add a language to Drupal core, you must gather the following information:

  1. How the language is written in its native language (for example, "ʻŌlelo Hawaiʻi")
  2. How the language is written in English (e.g. "Hawaiian")
  3. The "official" language code, usually 2 or 3 letters (e.g. "haw"). See The www.w3.org language tags guide for more. Ideally, it's already on the recognized list from iana.org.
  4. The "plural forms" for the language. Many languages only have 2 plural forms: singular and plural (everything else), but some have more distinct ways to write a phrase describing a variable number of items. Some languages need a different wording if there are 0 items, others special case 2 as well, and so on. The translatehouse.org pluralforms guide might list the language already. If not, you can read the official gettext() documentation about plural forms to understand how to define the correct value.

Create a translation team at localize.drupal.org

Once you have all the info you need, you can open an issue to create a language on localize.drupal.org. As it says in the sidebar of that site:

To get your group set up here, do the following: Look at the waiting list of languages if you find your language there, follow up on the issue found. Otherwise open an issue filling in your language name. State your team leader username on drupal.org (and make sure you log in on localize.drupal.org as well, so your local user copy is created). Do you have others to work with? Previous work you'll migrate? Tell us about it in the issue.

Anyone who will directly participate in translating to the language should log into localize.drupal.org. Be sure to explicitly state who should be the team manager(s), and if anyone else should be on the team. List both the username, and the l.d.o user ID.

Create a Drupal core issue

Create an issue in the Drupal core issue queue.  The issue should be 'Task' with a 'Normal' priority in the 'language system' component. In the 'Proposed resolution' comment why the language should be added. Save the issue and confirm the results. See #3336763: Add Hawaiian as a choice in core language selectors for an example.

Modify Drupal core to know about the language

It will help if you, or someone you know, can make the change to the code.

The only file in all of Drupal core that needs to be changed is core/lib/Drupal/Core/Language/LanguageManager.php. Modify the method LanguageManager::getStandardLanguageList() to include another entry in the array. Each entry is indexed by the language code (point 3 from key information) and the value is a sub array which includes at least two values, the English spelling and the native spelling of the language. The array can optionally indicate if the language is Right-to-Left (RTL), although this third argument defaults to LTR which is the correct value for most languages.

Once you've made the (hopefully 1 line) change to the array returned by LanguageManager::getStandardLanguageList(), contribute the change to the issue created above. See #3336763: Add Hawaiian as a choice in core language selectors for an example.

Help improve this page

Page status: No known problems

You can: