Let’s take a brief look at how translation contributions work in Drupal. This written tutorial is based on the free video, Translation in Drupal.
Layers of Translations
There are many layers of translatable text on a Drupal site.
First, there are the many user interface (UI) elements that contain text. For example, the Log In button, Add New Comment link, and the Home menu item. These are examples from Drupal core, but any contributed module or theme can contain additional translatable UI elements. If the developer of a contributed module or theme wrapped UI text in
t(), then that text is translatable.
Next, there's the content itself, as well as any custom UI elements you add to your site, like menu items. I won't cover that topic in this lesson. But if you want to learn about creating multilingual sites in Drupal, watch this video tutorial series: Using Drupal Chapter 8: Multilingual Sites. You'll learn how to harness different core and contributed modules to build a full-fledged multilingual site in Drupal 7.
In this lesson, we explore how to contribute translations to those out-of-the-box UI elements that are part of Drupal core or any contributed project.
What is Translatable?
Any string of text in Drupal’s UI is translatable. For example, the Log In button or Add New Comment link. From a developer’s perspective, any string wrapped in the
t() function is translatable. Button text, field captions, menu-item labels, and messages are all translatable strings.
Drupal core, as well as many contributed modules and themes, has complete or partially-complete translations of Drupal's UI text. In cases where not all of the UI text has been translated, the text defaults to English. No language translation is complete for every contributed module and theme, so there's a need for more translation.
This site is part of the drupal.org infrastructure. It’s a central location where contributors can maintain translations for any project on drupal.org, including core, contributed modules, and themes.
Let's me take you on an educational tour of localize.drupal.org. By the end of this tour, you'll learn:
- How to find and join translation groups in your language of choice
- How to filter and find translatable strings in any given project
- How to suggest a translation
- How to locate documentation
On the homepage of localize.drupal.org you’ll find an overview of the site, some helpful links to documentation, and a table of languages that currently have a group on localize.drupal.org. This table includes information about the language’s Drupal core progress, and the number of contributors to the language's translation efforts.
Homepage of localize.drupal.org
In the sidebar, you can navigate to the page for a language's translation group, or— if you already know the name of the project to which you want to contribute—fill in the auto complete field and select the appropriate project. Also in the sidebar are translation-related statistics, news, a link to the issue queue for localize.drupal.org, and instructions on how to create a new translation group if you want to add one.
Find a Translation Group
There are 2 primary ways to find a translation group page. From the home page on localize.drupal.org, locate and select a language from the table in the main region of the page.
Alternatively, under Quick Navigation in the sidebar, pick a language from the drop-down field and click Go There.
I'm going to select the English (British) translation group for the purposes of this tutorial, but you can choose whichever language you like.
As you can see from the the English (British) page, group pages typically have an overview of the group's goals and objectives, documentation, various statistics related to the group, and a list of top translation projects on drupal.org.
Join a Translation Group
Before you can begin contributing translations, you need to join the translation group. On most translation group pages, there will be a Join Group button in the sidebar. Make sure you are signed in, then click this button and confirm your choice on the next page.
Filter and Find Translatable Texts
Now you can begin the process of submitting translations. Proceed by locating untranslated text.
Return to the Translations Homepage at localize.drupal.org, and select the drupal.org project to which you want to contribute. Under Quick Navigation, pick a project. (Note that your new language group has been preselected.) For this tutorial, type "Drupal core". Then select it from the autocomplete list, and click Go There to continue.
Near the top of the page, you'll see some exposed filters. Click Reveal More Filters in the lower left side of this region to see all of the available filters.
Let's find all untranslated text with the word "authorize" in the latest Drupal 8 beta (as of the time this article was published).
- Under Project, ensure that Drupal Core is selected.
- For Release, select 8.0.0-beta9.
- Under Status, there are 2 drop-down elements. In the first drop-down, select Untranslated. Then click the Filter button in the upper right of the filters box.
- Type the word, "authorize" into the Contains text filter.
- Click the Filter button in the upper right of the filters region.
In the results that follow, notice the Source text is in the left column and the Translations are in the right column.
You can see that (not translated) is selected for these results, since we filtered for Untranslated strings.
Suggest a Translation
Click the pencil icon in the the source text to provide a suggestion for a translation.
In the Translations column, the entire string will appear in a textfield for editing. Type the translation for the entire string. Here we just need to change "authorize" to "authorise", but typically you will translate the entire string.
Continue translating other strings on this page. Then click Save Changes at the bottom of the page.
Congratulations! You just contributed a translation suggestion to Drupal core.
Only administrators of a translation group can approve a suggestion. But the translation will appear in the language's downloadable translation package once it's approved and selected.
Hooked yet? To learn more about contributing to localization efforts for drupal.org projects, check out the overview and introductory text on the Translations Homepage at localize.drupal.org. You can find information related to:
- Localized Drupal — a distribution that installs Drupal with user interface translations pulled automatically from localize.drupal.org.
- Setting up a local site using Localize Drupal to contribute translations while clicking around a site.
- More about how to translate Drupal to your language.
- And finally, how to contribute translations using the localization server.
To watch the free video on this topic, check out Translation in Drupal.