Translation - WikipediaLibrary/TWLight GitHub Wiki

Translation

Translations are supported in the platform. Please make sure to correctly comment new or updated strings with guidance for translators - to do so, write a comment to the line preceding the string which starts # Translators: in python files or {% comment %}Translators: in HTML.

The translator comment must be placed on the line immediately above the start of the translated string. For example, this will not be picked up by Django:

# Translators: This is a translation comment
x = y + 1
variable = _("Translated string")

The comment must immediately precede the translatable string:

# Translators: This is a translation comment
variable = _("Translated string")

Multi-line comments are also permitted:

# Translators: This is a translation comment
# This is still a translation comment
variable = _("Translated string")

In HTML files, make sure to wrap multiline strings with {% blocktrans trimmed %}, not just {% blocktrans %}, to avoid whitespace and indentation formatting issues.

Where possible, try to keep code and HTML tags outside of strings (i.e. <p>{% trans "Text" %}</p> rather than {% trans "<p>Text</p>" %}) to avoid confusion for translators. Don't, however, break up sentences into multiple translation blocks. Translators need to see the entire context of a string to translate it accurately.

String translation will only work if the first line of the string is on the same line as the ugettext function. For example, this will not function correctly:

_(
"A very long string which "
"requires a newline"
)

Instead, the first line must be level with the function call:

_("A very long string which "
"requires a newline"
)

Translatewiki

Translations for the platform are handled via translatewiki.net, where volunteer contributors add translations. These are synced twice a week - on Mondays and Thursdays.

See Editing resource descriptions and [https://github.com/WikipediaLibrary/TWLight/wiki/Editing-tags](Editing tags) for guidance on adding and editing that data.

⚠️ **GitHub.com Fallback** ⚠️