Changes between Version 34 and Version 36 of DevelopersGuide/StyleGuide


Ignore:
Timestamp:
(multiple changes)
Author:
(multiple changes)
Comment:
(multiple changes)

Legend:

Unmodified
Added
Removed
Modified
  • DevelopersGuide/StyleGuide

    v34 v36  
    11[[TranslatedPages]]
    22= Development Guidelines =
     3
     4[[PageOutline(2-2,Table of content,inline)]]
    35
    46== How your code should look like ==
     
    6971 * make sure you use {{{tr(...)}}} for all localized strings
    7072   {{{
     73   #!java
    7174   import import static org.openstreetmap.josm.tools.I18n.tr;
    7275
     
    8285   }}}
    8386
    84 
    8587 * never assemble localized messages with {{{+}}}. Use format
    8688   placeholders instead.
     
    8991   {{{new JLabel(tr("My Label " + labelId));}}}
    9092
    91 
    9293   '''DO'''
    9394   {{{new JLabel(tr("My Label {0}",labelId));}}}
    9495
    9596   Only exception: {{{+}}} can be used to break long lines of non-variable texts.
     97   The placeholders are mandatory in simple translations.
    9698
    97  * When using apostrophe, the following rules apply:
     99 * When using apostrophe in the source string, it needs to be escaped by another apostrophe (Like backslash in C):[[BR]]
     100   {{{#!java
     101   new JButton(tr("Don''t press me!"))
     102   }}}
    98103
    99    For all {{{tr}}} the apostrophe is special. (Like backslash in C)[[BR]]
    100    It needs to be escaped by another apostrophe:
     104 * A translation context can be set with {{{trc(...)}}}. Additional hints to translators are given by java comments at the function:
     105   {{{#!java
     106   /* I18n: house number, street as parameter; place number first for visibility */
     107   msg = tr("House number {0} at {1}", s, t);
     108   }}}
    101109
    102    {{{new JButton(tr("Don''t press me more than {0} times!", n))}}}
     110 * Use {{{trn(...)}}} to let translators choose the language specific plural:
     111   {{{#!java
     112   msg = trn("Object deleted", "Objects deleted", del.size();
     113   
     114   // or with placeholders:
     115   //
     116   new JButton(trn(/* I18n: times needed, some name as parameter */
     117                       "Press {1} {0} times!", n, n, someName))
     118
     119   // The English singular source string must be given for identification
     120   // even when its logically invalid and won't occur. For consistency
     121   // the number placeholder should be set in it.
     122   //
     123   msg = trn("Combine {0} way", "Combine {0} ways", n, n);
     124   }}}
     125
     126 In plural segments no placeholder is mandatory for translators.
    103127
    104128----
    105 Back to [wiki:/DevelopersGuide Developers Guide]
     129Back to [wikitr:/DevelopersGuide Developers Guide]