308
edits
| Line 48: | Line 48: | ||
Please note that these automatically generated localization templates are not perfect. For technical reasons, there are often a handful of localizable strings which do not get automatically added into the template. When you notice these, you can simply duplicate one of the <code>msgctxt</code>-<code>msgid</code>-<code>msgstr</code> entries and fill in the appropriate details. This will often require that you take a look at the original command feed's source. | Please note that these automatically generated localization templates are not perfect. For technical reasons, there are often a handful of localizable strings which do not get automatically added into the template. When you notice these, you can simply duplicate one of the <code>msgctxt</code>-<code>msgid</code>-<code>msgstr</code> entries and fill in the appropriate details. This will often require that you take a look at the original command feed's source. | ||
== Examples == | == Examples and special cases == | ||
=== Two types of strings === | |||
There are, broadly speaking, two types of translation entries in Ubiquity command localization: '''properties''' and '''inline strings'''. | |||
==== Properties ==== | |||
'''Properties''' are metadata about the command that are in individual properties of command objects. Localizable properties include <code>names</code>, <code>help</code>, and <code>description</code>. As each command only has one each of these properties, there is only one <code>msgcntxt</code> of each kind. For example, a command like <code>twitter</code> would never have two different <code>twitter.names</code> localization entries. Even though it is logically somewhat redundant, these property entries still need to keep both their <code>msgctxt</code> and their <code>msgid</code>'s to function properly. | |||
Note in particular that the <code>names</code> translation may be a plurality of names, not just one. In this case, use the pipe (|) character to delimit the names: | |||
#. twitter command: | |||
#. use | to separate multiple name values: | |||
msgctxt "twitter.names" | |||
msgid "twitter|tweet|share using twitter" | |||
msgstr "呟く|呟いて|呟け|つぶやく|つぶやいて|つぶやけ|twitter|tweet" | |||
==== Inline strings ==== | |||
=== Multiline strings === | |||
Often the strings to localize—and their localizations—will be multiple lines long. In this case, the <code>po</code> format offers a special syntax to deal with such line breaks: | |||
msgctxt "digg.description" | |||
msgid "If not yet submitted, submits the page to Digg.\n" | |||
"Otherwise, it takes you to the story's Digg page." | |||
msgstr "このページを Digg にたれこみます。\n" | |||
"または該当する Digg ページを開きます。" | |||
The convention here is that if a line begins with a quote ("), it is the continuation of the line before it. In this case, newline characters (encoded <code>\n</code>) are not automatically inserted, so a <code>\n</code> must be inserted at the end of the line to mark that there is a newline there. Note that the <code>msgid</code> must match what is in the source code exactly, so it is best to leave the <code>msgid</code>'s as they are in the templates. | |||
<small>There is a [https://ubiquity.mozilla.com/trac/ticket/769 known bug] in Ubiquity 0.5 preventing these multi-line keys from being properly dealt with.</small> | |||
=== Shared keys === | |||
In some situations, a command author will write some shared code which is executed as part of the command's <code>preview</code> and <code>execute</code> or even between commands. | |||
In this special case, as it would be redundant to write the exact same translation entry twice for both <code>preview</code> and <code>execute</code> contexts, you can ''optionally'' make do without the msgctxt: | |||
# no message context | |||
msgid "original message" | |||
msgstr "translation" | |||
By not specifying a context, this same translation entry can be shared across any instance of the string "original message" in any <code>preview</code> or <code>execute</code> string in any command in that feed. You cannot, however, use shared keys to share translations between command feeds. | |||
Note however that there are instances in some languages where you would actually want to localize the two contexts' strings separately: for example, suppose the source language does not mark tense or aspect, but your target language does. A status message in that language may be the same in cases where the action is about to be done (in the <code>preview</code>) and when it was completed (in the <code>execute</code>) and you would thus want to translate these strings differently in the different (future/past) contexts. | |||
== Formatting templates == | == Formatting templates == | ||
edits