Qt Creator Translation Page: Difference between revisions
(Add to QtCreator; also to Translations.) |
(→Coding: fix markup, etc.) |
||
Line 32: | Line 32: | ||
=== Coding === | === Coding === | ||
* Add linguist comments | See also [https://techbase.kde.org/Development/Tutorials/Localization/i18n_Mistakes KDE's tutorial]. | ||
* Add linguist comments to clarify where appropriate: | |||
<pre> | <pre> | ||
//: Contact book "Add person" button label | //: Contact book "Add person" button label | ||
return tr("Add"); | return tr("Add"); | ||
</pre> | </pre> | ||
* If the class is not a <code>Q_OBJECT</code>, use | * If the class is not a <code>Q_OBJECT</code>, add | ||
<pre> | |||
Q_DECLARE_TR_FUNCTIONS(<class name>) | |||
</pre> | |||
to it. Alternatively, you may use | |||
<pre> | <pre> | ||
QCoreApplication::translate("class | QCoreApplication::translate("<class name>", "text") | ||
</pre> | </pre> | ||
if there are only few translatable strings in it. | |||
* Do '''NOT''' use <code>QObject::tr()</code> as this is confusing since the messages appear grouped by class context in linguist. | * Do '''NOT''' use <code>QObject::tr()</code> as this is confusing since the messages appear grouped by class context in linguist. | ||
* Avoid contractions, do not shout at users using exclamation marks: <code>tr("Can't open the file!")</code> should be <code>tr("Cannot open the file.")</code>. | * Avoid contractions, and do not shout at users using exclamation marks: <code>tr("Can't open the file!")</code> should be <code>tr("Cannot open the file.")</code>. | ||
* Use plurals correctly: <code>tr("%1 files found").arg(number)</code> should be <code>tr("%n files found", 0, number)</code>. | * Use plurals correctly: <code>tr("%1 files found").arg(number)</code> should be <code>tr("%n files found", 0, number)</code>. | ||
* Be aware that articles have a grammatical gender in some languages and sentences cannot be as easily constructed as in English, so avoid | * Be aware that articles have a grammatical gender in some languages and sentences cannot be as easily constructed as in English, so avoid word puzzles like | ||
<pre> | <pre> | ||
tr("%1 failed").arg(someCondition ? "the operation" : "opening a file"). | tr("%1 failed").arg(someCondition ? "the operation" : "opening a file"). | ||
Line 59: | Line 66: | ||
* In Qt Designer, preferably use plain text for Tooltips. Should you want some extra formatting, write short, canonical HTML in the source tab of the rich text editor: | * In Qt Designer, preferably use plain text for Tooltips. Should you want some extra formatting, write short, canonical HTML in the source tab of the rich text editor: | ||
<pre> | <pre> | ||
<html><head/><body><b>Note:</b>foo bar ... | |||
</pre> | </pre> | ||
If you use Qt Designer's rich text editor, always also look at the source tab to verify that reasonably simple HTML was generated. | |||
* Observe the [http://developer.kde.org/documentation/standards/kde/style/basics/labels.html#items KDE UI Capitalization guidelines] on Capitalization of User Interface Texts should be observed. Here is a short summary: Two major styles are used, book title and sentence style: | * Observe the [http://developer.kde.org/documentation/standards/kde/style/basics/labels.html#items KDE UI Capitalization guidelines] on Capitalization of User Interface Texts should be observed. Here is a short summary: Two major styles are used, book title and sentence style: | ||
** Example of Book Title Capitalization | ** Example of Book Title Capitalization | ||
*** Use it for: | |||
**** Titles (window, dialog, group box, tab, list view columns, and so on) | |||
**** Functions (menu items, buttons) | |||
**** Selectable items (combobox items, listbox items, tree list items, and so on) | |||
** Example of sentence style capitalization | ** Example of sentence style capitalization | ||
Use | *** Use it for: | ||
** | **** Labels | ||
**** Tool tips | |||
** | **** Descriptive text | ||
** | |||
** Tool tips | |||
** Descriptive text |
Revision as of 13:33, 6 April 2021
Contributed Translations
The authoritative resource about contributing translations is the Qt Localization page. This page is meant as a place to collect information on existing translation efforts. Please feel free to add information on the languages you want to work on and announce your intent at the Qt localization list. Some contact information would be great, too:-)
Thank you!
en
There is no English translation- it is the native language of Qt Creator. Regional variants and proper plurals are thinkable, but nobody cared enough to do a translation for just that so far.
de
The German translation is maintained as part of Qt Creator itself. Please check the Qt Creator Page for contact information
jp
Japanese translation seems to be hosted here
See the blog post.
other languages
Active Russian, Chinese and Slovenian translation teams exist as well. TODO: elaborate on this.
User Interface Text Conventions
The below guidelines explain what is required to make it easy for interpreters to create good translations for Qt-based applications using Qt Linguist or other tools. Basically, as a developer, always be aware that an interpreter commissioned to create a translation of your code might have no knowledge of software development at all.
Coding
See also KDE's tutorial.
- Add linguist comments to clarify where appropriate:
//: Contact book "Add person" button label return tr("Add");
- If the class is not a , add
Q_OBJECT
Q_DECLARE_TR_FUNCTIONS(<class name>)
to it. Alternatively, you may use
QCoreApplication::translate("<class name>", "text")
if there are only few translatable strings in it.
- Do NOT use as this is confusing since the messages appear grouped by class context in linguist.
QObject::tr()
- Avoid contractions, and do not shout at users using exclamation marks: should be
tr("Can't open the file!")
.tr("Cannot open the file.")
- Use plurals correctly: should be
tr("%1 files found").arg(number)
.tr("%n files found", 0, number)
- Be aware that articles have a grammatical gender in some languages and sentences cannot be as easily constructed as in English, so avoid word puzzles like
tr("%1 failed").arg(someCondition ? "the operation" : "opening a file").
- Try to avoid concatenating messages (use "%1" formatting instead), as some constructions may not work for grammar reasons. Also, NEVER use leading/trailing/multiple blanks to achieve formatting in a message, as they will invariably be clobbered by translators (think Excel, other tools). So,
tr("Foo failed: ") + message
should be
tr("Foo failed: %1").arg(message)
- When using Qt Designer, mark text that is not supposed to be translated (for example, dummy data or initial values for label texts that will be set programatically) as such (check off 'translate' in the property editor).
- In Qt Designer, preferably use plain text for Tooltips. Should you want some extra formatting, write short, canonical HTML in the source tab of the rich text editor:
<html><head/><body><b>Note:</b>foo bar ...
If you use Qt Designer's rich text editor, always also look at the source tab to verify that reasonably simple HTML was generated.
- Observe the KDE UI Capitalization guidelines on Capitalization of User Interface Texts should be observed. Here is a short summary: Two major styles are used, book title and sentence style:
- Example of Book Title Capitalization
- Use it for:
- Titles (window, dialog, group box, tab, list view columns, and so on)
- Functions (menu items, buttons)
- Selectable items (combobox items, listbox items, tree list items, and so on)
- Use it for:
- Example of sentence style capitalization
- Use it for:
- Labels
- Tool tips
- Descriptive text
- Use it for:
- Example of Book Title Capitalization