Difference between revisions of "Development/Tutorials/Localization/Message Appearance"

Jump to: navigation, search
m (typo)
 
(23 intermediate revisions by one user not shown)
Line 1: Line 1:
= What Translators See =
+
{{TutorialBrowser|
  
This page is a short summary that tries to show how translators see the translatable messages. The information that translators see about a given message also depends on where the message comes from.
+
series=Localization|
  
(The idea is that I'll move this page to somewhere once it's at least somewhat useful.)
+
name=Understanding How Messages Appear to Translators|
  
== Messages coming from i18n() and friends ==
+
pre=[[../i18n|Writing Applications With Localization in Mind]]|
  
For these messages translators will only see the following:
+
}}
 +
 
 +
== Abstract ==
 +
 
 +
By reading the source code it can be hard to see how translators would see (or not see) the context of a message. This page is a short summary intended mostly for developers that lists the major points of what can be seen from the PO files and gives a few examples.
 +
 
 +
== Introduction ==
 +
 
 +
Not all context information that can be seen or figured by reading the source code is extracted to the PO files. Because the amount and type of extracted information depends on from where and how the message is extracted, the rest of this page is divided into different sources of translatable messages.
 +
 
 +
The goal of this page is only to serve as an introduction and quick reference for this topic. For more information one can always look at the generated template (.pot) files, either by opening them in any text editor or with [http://userbase.kde.org/Lokalize Lokalize]. In KDE infrastructure they can be found in [[Getting_Started/Sources/Subversion|SVN]] under branches/stable/l10n-kde4/templates and trunk/l10n-kde4/templates.
 +
 
 +
== Messages translated using i18n() and friends ==
 +
 
 +
For these messages the template files will only contain the following:
 
*the source string (and plural form if i18np is used)
 
*the source string (and plural form if i18np is used)
 
*the context parameter if i18nc is used
 
*the context parameter if i18nc is used
 
*the code comment beginning with "i18n:" if used
 
*the code comment beginning with "i18n:" if used
*list of file names and row numbers the messages appears in
+
*list of file names with row numbers for the locations the message appears in
 +
*the order in which the messages were extracted (sometimes useful, but not a replacement for other context information)
  
 
For example this message:
 
For example this message:
Line 17: Line 32:
 
<syntaxhighlight lang="cpp-qt">
 
<syntaxhighlight lang="cpp-qt">
 
QString msg = i18nc("%1 and %2 are file names", "Do you want to replace %1 with %2?",
 
QString msg = i18nc("%1 and %2 are file names", "Do you want to replace %1 with %2?",
                  oldFile, newFile)
+
                    oldFile, newFile);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Appears like this:
+
Appears like this in Lokalize:
  
<syntaxhighlight lang="gettext">
+
[[File:What_Translators_See_i18n.png]]
#: example.cpp:57
+
#, kde-format
+
msgctxt "%1 and %2 are file names"
+
msgid "Do you want to replace file %1 with file %2?"
+
msgstr ""
+
</syntaxhighlight>
+
  
(Perhaps use a screenshot of Lokalize here?)
+
If the message appears in many places, the context information from all the locations is shown.
  
== Messages in UI files ==
+
== Messages in .ui files ==
  
For these messages translators will see everything that they see for messages coming from i18n() and friends. They will additionally see the following:
+
For these messages the template files will contain everything that they contain for messages translated using i18n() and friends. They will additionally contain the following:
*the type and name of the widget the message it appears in
+
*the type and name of the widget the message appears in
 
*the name of the property the message is a value for
 
*the name of the property the message is a value for
  
If the message appears in many places, the context information from all the places is shown.
+
Examples:
  
For example:
+
[[File:What_Translators_See_ui.png]]
  
(Mention that not all translators know how to infer context from class names of widgets.)
+
[[File:What_Translators_See_ui2.png]]
 +
 
 +
For example from "property (displayFormat), widget (QDateEdit, dateEdit)" it could be inferred that the translation should use the specific format that QDate's toString() accepts. Some translators cannot infer this, though, so it is a good idea to additionally use "(qtdt-format)" as context as mentioned in [[Development/Tutorials/Localization/i18n|Writing Applications With Localization in Mind]].
  
 
== Messages in .kcfg files ==
 
== Messages in .kcfg files ==
  
(TODO)
+
For these messages the template files will contain everything that they contain for messages translated using i18n() and friends. They will additionally contain the following:
 +
*the tag the string is for
 +
*the name of the entry the tag is for
 +
*the name of the group the entry belongs to
 +
 
 +
For example:
 +
 
 +
[[File:What_Translators_See_kcfg.png]]

Latest revision as of 04:33, 30 November 2013

Understanding How Messages Appear to Translators
Tutorial Series   Localization
Previous   Writing Applications With Localization in Mind
What's Next   n/a
Further Reading   n/a

Contents

[edit] Abstract

By reading the source code it can be hard to see how translators would see (or not see) the context of a message. This page is a short summary intended mostly for developers that lists the major points of what can be seen from the PO files and gives a few examples.

[edit] Introduction

Not all context information that can be seen or figured by reading the source code is extracted to the PO files. Because the amount and type of extracted information depends on from where and how the message is extracted, the rest of this page is divided into different sources of translatable messages.

The goal of this page is only to serve as an introduction and quick reference for this topic. For more information one can always look at the generated template (.pot) files, either by opening them in any text editor or with Lokalize. In KDE infrastructure they can be found in SVN under branches/stable/l10n-kde4/templates and trunk/l10n-kde4/templates.

[edit] Messages translated using i18n() and friends

For these messages the template files will only contain the following:

  • the source string (and plural form if i18np is used)
  • the context parameter if i18nc is used
  • the code comment beginning with "i18n:" if used
  • list of file names with row numbers for the locations the message appears in
  • the order in which the messages were extracted (sometimes useful, but not a replacement for other context information)

For example this message:

QString msg = i18nc("%1 and %2 are file names", "Do you want to replace %1 with %2?",
                    oldFile, newFile);

Appears like this in Lokalize:

What Translators See i18n.png

If the message appears in many places, the context information from all the locations is shown.

[edit] Messages in .ui files

For these messages the template files will contain everything that they contain for messages translated using i18n() and friends. They will additionally contain the following:

  • the type and name of the widget the message appears in
  • the name of the property the message is a value for

Examples:

What Translators See ui.png

What Translators See ui2.png

For example from "property (displayFormat), widget (QDateEdit, dateEdit)" it could be inferred that the translation should use the specific format that QDate's toString() accepts. Some translators cannot infer this, though, so it is a good idea to additionally use "(qtdt-format)" as context as mentioned in Writing Applications With Localization in Mind.

[edit] Messages in .kcfg files

For these messages the template files will contain everything that they contain for messages translated using i18n() and friends. They will additionally contain the following:

  • the tag the string is for
  • the name of the entry the tag is for
  • the name of the group the entry belongs to

For example:

What Translators See kcfg.png


This page was last modified on 30 November 2013, at 04:33. This page has been accessed 1,909 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal