Development/Tutorials/Localization/Message Appearance: Difference between revisions

From KDE TechBase
No edit summary
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
= What Translators See =
= Abstract =


This page is a short summary that tries to show how translators see the translatable messages. This is because it might not be obvious that the template files don't contain all the context information a developer sees in the source code. The information that translators see about a given message also depends on where the message comes from.
This page is a short summary that tries to show how translators see the translatable messages. This is intended primarily for developers who want to see what kind of context information can be seen in the translation files and how not everything that can be seen by reading the source code is visible to translators. The information that translators see about a given message also depends on where the message comes from.


For more information one can always look at the template (pot) files. (TODO: Write where they can be found.)
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 are in [[Getting_Started/Sources/Subversion|SVN]] under branches/stable/l10n-kde4/templates and trunk/l10n-kde4/templates.


(The idea is that I'll move this page to somewhere once it's at least somewhat useful.)
(The idea is that I'll move this page to somewhere once it's at least somewhat useful.)
Line 14: Line 14:
*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 and row numbers the messages appears in
*the order in which the messages were extracted (sometimes useful, but not a replacement for other context information)


If the message appears in many places, the context information from all the places is shown.
If the message appears in many places, the context information from all the places is shown.
Line 24: Line 25:
</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 have a screenshot of Lokalize here?)


== Messages in UI files ==
== Messages in UI files ==
Line 44: Line 37:
Examples:
Examples:


<syntaxhighlight lang="gettext">
[[File:What_Translators_See_ui.png]]
#. i18n: ectx: property (displayFormat), widget (QDateEdit, dateEdit)
#: mainwindowview.ui:137
msgid "d/M/yyyy"
msgstr ""
 
#. i18n: ectx: property (toolTip), widget (KComboBox, maintypeBox)
#. i18n: ectx: property (whatsThis), widget (KComboBox, maintypeBox)
#: mainwindowview.ui:154 mainwindowview.ui:157
msgid "The main game of the theme"
msgstr ""
 
#. i18n: ectx: property (title), widget (QGroupBox, groupBox_2)
#: conf/dlgeditorbase.ui:19 conf/preferencesdialog.cpp:56
msgid "Editor"
msgstr ""
</syntaxhighlight>


(Perhaps have some screenshots of Lokalize here?)
[[File:What_Translators_See_ui2.png]]


For example from "property (displayFormat), widget (QDateEdit, dateEdit)" it could be inferred that the translatin should use the specific format that QDate's toString() accepts. Some translators cannot infer this, though, so it is good to additionally use "(qtdt-format)" as context as said on page [[Development/Tutorials/Localization/i18n]].
For example from "property (displayFormat), widget (QDateEdit, dateEdit)" it could be inferred that the translatin should use the specific format that QDate's toString() accepts. Some translators cannot infer this, though, so it is good to additionally use "(qtdt-format)" as context as said on page [[Development/Tutorials/Localization/i18n]].
Line 75: Line 52:
Example:
Example:


<syntaxhighlight lang="gettext">
[[File:What_Translators_See_kcfg.png]]
#. i18n: ectx: label, entry (UseGL), group (View)
#: kstars.cpp:176 kstars.kcfg:726 kstarsinit.cpp:238 skymap.cpp:1150
#: skymap.cpp:1158 skymap.cpp:1166
msgid "Switch to OpenGL backend"
msgstr ""
</syntaxhighlight>

Revision as of 20:36, 21 July 2013

Abstract

This page is a short summary that tries to show how translators see the translatable messages. This is intended primarily for developers who want to see what kind of context information can be seen in the translation files and how not everything that can be seen by reading the source code is visible to translators. The information that translators see about a given message also depends on where the message comes from.

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 are in SVN under branches/stable/l10n-kde4/templates and trunk/l10n-kde4/templates.

(The idea is that I'll move this page to somewhere once it's at least somewhat useful.)

Messages coming from i18n() and friends

For these messages translators will only see 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 and row numbers the messages appears in
  • the order in which the messages were extracted (sometimes useful, but not a replacement for other context information)

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

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:

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:

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

Examples:

For example from "property (displayFormat), widget (QDateEdit, dateEdit)" it could be inferred that the translatin should use the specific format that QDate's toString() accepts. Some translators cannot infer this, though, so it is good to additionally use "(qtdt-format)" as context as said on page Development/Tutorials/Localization/i18n.

Messages in .kcfg files

All the things mentioned in the first section also apply here. Additionally the following context information is automatically added:

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

Example: