UI Text Conventions: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=UI Text Conventions=
h1. UI Text Conventions


==Guidelines==
== Guidelines ==


The points listed below help you to make sure the text strings presented to the user are easy to handle by interpreters for localized applications. One should basically keep in mind that user interface text strings (enclosed in tr()-calls) are potentially extracted from of the source code in the translation process and thus the interpreter does not necessarily know the source code context of the messages.
The points listed below help you to make sure the text strings presented to the user are easy to handle by interpreters for localized applications. One should basically keep in mind that user interface text strings (enclosed in tr()-calls) are potentially extracted from of the source code in the translation process and thus the interpreter does not necessarily know the source code context of the messages.
Line 7: Line 7:
* Add linguist comments ( //:) to clarify where appropriate:
* Add linguist comments ( //:) to clarify where appropriate:


* We follow the [http://developer.kde.org/documentation/standards/kde/style/basics/labels.html#items Capitalization Guidelines of the <span class="caps">KDE</span> Project] ''[developer.kde.org]''
<code>//: Contact book &quot;Add person&amp;quot; button label<br />return tr(&quot;Add&amp;quot;);<br /></code>


==Capitalization Guides Short Reference==
* If the class is not a Q_OBJECT, use <code>QCoreApplication::translate(&quot;class context&amp;quot;, &quot;message&amp;quot;)<code> or consider using <code>Q_DECLARE_TR_FUNCTIONS<code>
 
* Do not use </code>QObject::tr()</code> which is confusing since the messages appear grouped by class context in linguist, which messages tied to QObject do not have.
 
* Avoid contractions and do not shout at users using exclamation marks: <code>tr(&quot;Cannot open the file.&quot;)<code> instead of<br /></code>tr(&quot;Can't open the file!&quot;)</code>
 
* Use plurals correctly: <code>tr(&quot;%n files found&amp;quot;, 0, number)<code> instead of <code>tr(&quot;%1 files found&amp;quot;).arg(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 things like: </code>tr(&quot;%1 failed&amp;quot;).arg(someCondition ? &quot;the operation&amp;quot; : &quot;opening a file&amp;quot;)</code>
 
* Try to avoid concatenating messages (use &quot;%1&amp;quot; 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): <code>tr(&quot;Foo failed: %1&amp;quot;).arg(message)<code> instead of <code>tr(&quot;Foo failed: &quot;) + message<code>
 
* 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: </code>&amp;lt;html&amp;amp;gt;&amp;lt;head/&amp;gt;&amp;lt;body&amp;amp;gt;&amp;lt;b&amp;gt;Note:&lt;/b&amp;gt; text.</code> In Qt 4.7, only the source tab of the Designer rich text editor should be used. The automatic conversion performed by the rich text editor tab produces a lot of redundant stylesheet information and hard-coded fonts that look bad on other platforms and make translation in Linguist difficult. Qt Designer 4.8 has a feature simplifying the rich text (on by default), still, you should verify by looking at the source tab.
 
* We follow the &quot;Capitalization Guidelines of the KDE Project&amp;quot;:http://developer.kde.org/documentation/standards/kde/style/basics/labels.html#items
 
== Capitalization Guides Short Reference ==


Here is a short summary of the above mentioned Capitalization Guidelines. Two major styles are used, book title and sentence style:
Here is a short summary of the above mentioned Capitalization Guidelines. Two major styles are used, book title and sentence style:
Line 16: Line 32:
* Example of sentence style capitalization
* Example of sentence style capitalization


Use book style for:
Use book style for:<br />* Titles (window, dialog, group box, tab, list view columns, and so on)<br />* Functions (menu items, buttons)<br />* Selectable items (combobox items, listbox items, tree list items, and so on)
 
* 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 sentence style for:


* Labels
Use sentence style for:<br />* Labels<br />* Tool tips<br />* Descriptive text
* Tool tips
* Descriptive text
* Other non-heading/title text

Revision as of 11:08, 24 February 2015

h1. UI Text Conventions

Guidelines

The points listed below help you to make sure the text strings presented to the user are easy to handle by interpreters for localized applications. One should basically keep in mind that user interface text strings (enclosed in tr()-calls) are potentially extracted from of the source code in the translation process and thus the interpreter does not necessarily know the source code context of the messages.

  • Add linguist comments ( //:) to clarify where appropriate:
//: Contact book &quot;Add person&amp;quot; button label<br />return tr(&quot;Add&amp;quot;);<br />
  • If the class is not a Q_OBJECT, use
    QCoreApplication::translate(&quot;class context&amp;quot;, &quot;message&amp;quot;)<code> or consider using <code>Q_DECLARE_TR_FUNCTIONS<code>
    
    * Do not use
    
    QObject::tr() which is confusing since the messages appear grouped by class context in linguist, which messages tied to QObject do not have.
  • Avoid contractions and do not shout at users using exclamation marks:
    tr(&quot;Cannot open the file.&quot;)<code> instead of<br />
    
    tr("Can't open the file!")
  • Use plurals correctly:
    tr(&quot;%n files found&amp;quot;, 0, number)<code> instead of <code>tr(&quot;%1 files found&amp;quot;).arg(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 things like:
    
    tr("%1 failed&quot;).arg(someCondition ? "the operation&quot; : "opening a file&quot;)
  • Try to avoid concatenating messages (use "%1&quot; 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):
    tr(&quot;Foo failed: %1&amp;quot;).arg(message)<code> instead of <code>tr(&quot;Foo failed: &quot;) + message<code>
    
    * 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:
    
    &lt;html&amp;gt;&lt;head/&gt;&lt;body&amp;gt;&lt;b&gt;Note:</b&gt; text. In Qt 4.7, only the source tab of the Designer rich text editor should be used. The automatic conversion performed by the rich text editor tab produces a lot of redundant stylesheet information and hard-coded fonts that look bad on other platforms and make translation in Linguist difficult. Qt Designer 4.8 has a feature simplifying the rich text (on by default), still, you should verify by looking at the source tab.

Capitalization Guides Short Reference

Here is a short summary of the above mentioned Capitalization Guidelines. Two major styles are used, book title and sentence style:

  • Example of Book Title Capitalization
  • Example of sentence style capitalization

Use book style 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 sentence style for:
* Labels
* Tool tips
* Descriptive text