Changes between Version 34 and Version 36 of DevelopersGuide/StyleGuide
- Timestamp:
- (multiple changes)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DevelopersGuide/StyleGuide
v34 v36 1 1 [[TranslatedPages]] 2 2 = Development Guidelines = 3 4 [[PageOutline(2-2,Table of content,inline)]] 3 5 4 6 == How your code should look like == … … 69 71 * make sure you use {{{tr(...)}}} for all localized strings 70 72 {{{ 73 #!java 71 74 import import static org.openstreetmap.josm.tools.I18n.tr; 72 75 … … 82 85 }}} 83 86 84 85 87 * never assemble localized messages with {{{+}}}. Use format 86 88 placeholders instead. … … 89 91 {{{new JLabel(tr("My Label " + labelId));}}} 90 92 91 92 93 '''DO''' 93 94 {{{new JLabel(tr("My Label {0}",labelId));}}} 94 95 95 96 Only exception: {{{+}}} can be used to break long lines of non-variable texts. 97 The placeholders are mandatory in simple translations. 96 98 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 }}} 98 103 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 }}} 101 109 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. 103 127 104 128 ---- 105 Back to [wiki :/DevelopersGuide Developers Guide]129 Back to [wikitr:/DevelopersGuide Developers Guide]