source: josm/trunk/src/org/openstreetmap/josm/tools/I18n.java@ 13849

Last change on this file since 13849 was 13790, checked in by Don-vip, 6 years ago

see #16215 - Add Korean translation

  • Property svn:eol-style set to native
File size: 25.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import java.io.BufferedInputStream;
5import java.io.File;
6import java.io.IOException;
7import java.io.InputStream;
8import java.lang.annotation.Retention;
9import java.lang.annotation.RetentionPolicy;
10import java.net.URL;
11import java.nio.charset.StandardCharsets;
12import java.nio.file.InvalidPathException;
13import java.text.MessageFormat;
14import java.util.ArrayList;
15import java.util.Arrays;
16import java.util.Collection;
17import java.util.Comparator;
18import java.util.HashMap;
19import java.util.Locale;
20import java.util.Map;
21import java.util.zip.ZipEntry;
22import java.util.zip.ZipFile;
23
24/**
25 * Internationalisation support.
26 *
27 * @author Immanuel.Scholz
28 */
29public final class I18n {
30
31 /**
32 * This annotates strings which do not permit a clean i18n. This is mostly due to strings
33 * containing two nouns which can occur in singular or plural form.
34 * <br>
35 * No behaviour is associated with this annotation.
36 */
37 @Retention(RetentionPolicy.SOURCE)
38 public @interface QuirkyPluralString {
39 }
40
41 private I18n() {
42 // Hide default constructor for utils classes
43 }
44
45 /**
46 * Enumeration of possible plural modes. It allows us to identify and implement logical conditions of
47 * plural forms defined on <a href="https://help.launchpad.net/Translations/PluralForms">Launchpad</a>.
48 * See <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html">CLDR</a>
49 * for another complete list.
50 * @see #pluralEval
51 */
52 private enum PluralMode {
53 /** Plural = Not 1. This is the default for many languages, including English: 1 day, but 0 days or 2 days. */
54 MODE_NOTONE,
55 /** No plural. Mainly for Asian languages (Indonesian, Chinese, Japanese, ...) */
56 MODE_NONE,
57 /** Plural = Greater than 1. For some latin languages (French, Brazilian Portuguese) */
58 MODE_GREATERONE,
59 /* Special mode for
60 * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ar">Arabic</a>.*
61 MODE_AR,*/
62 /** Special mode for
63 * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#cs">Czech</a>. */
64 MODE_CS,
65 /** Special mode for
66 * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#pl">Polish</a>. */
67 MODE_PL,
68 /* Special mode for
69 * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ro">Romanian</a>.*
70 MODE_RO,*/
71 /** Special mode for
72 * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#lt">Lithuanian</a>. */
73 MODE_LT,
74 /** Special mode for
75 * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#ru">Russian</a>. */
76 MODE_RU,
77 /** Special mode for
78 * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#sk">Slovak</a>. */
79 MODE_SK,
80 /* Special mode for
81 * <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#sl">Slovenian</a>.*
82 MODE_SL,*/
83 }
84
85 private static volatile PluralMode pluralMode = PluralMode.MODE_NOTONE; /* english default */
86 private static volatile String loadedCode = "en";
87
88 /** Map (english/locale) of singular strings **/
89 private static volatile Map<String, String> strings;
90 /** Map (english/locale) of plural strings **/
91 private static volatile Map<String, String[]> pstrings;
92 private static Map<String, PluralMode> languages = new HashMap<>();
93 static {
94 //languages.put("ar", PluralMode.MODE_AR);
95 languages.put("ast", PluralMode.MODE_NOTONE);
96 languages.put("bg", PluralMode.MODE_NOTONE);
97 languages.put("be", PluralMode.MODE_RU);
98 languages.put("ca", PluralMode.MODE_NOTONE);
99 languages.put("ca@valencia", PluralMode.MODE_NOTONE);
100 languages.put("cs", PluralMode.MODE_CS);
101 languages.put("da", PluralMode.MODE_NOTONE);
102 languages.put("de", PluralMode.MODE_NOTONE);
103 languages.put("el", PluralMode.MODE_NOTONE);
104 languages.put("en_AU", PluralMode.MODE_NOTONE);
105 languages.put("en_GB", PluralMode.MODE_NOTONE);
106 languages.put("es", PluralMode.MODE_NOTONE);
107 languages.put("et", PluralMode.MODE_NOTONE);
108 //languages.put("eu", PluralMode.MODE_NOTONE);
109 languages.put("fi", PluralMode.MODE_NOTONE);
110 languages.put("fr", PluralMode.MODE_GREATERONE);
111 languages.put("gl", PluralMode.MODE_NOTONE);
112 //languages.put("he", PluralMode.MODE_NOTONE);
113 languages.put("hu", PluralMode.MODE_NOTONE);
114 languages.put("id", PluralMode.MODE_NONE);
115 //languages.put("is", PluralMode.MODE_NOTONE);
116 languages.put("it", PluralMode.MODE_NOTONE);
117 languages.put("ja", PluralMode.MODE_NONE);
118 languages.put("ko", PluralMode.MODE_NONE);
119 // fully supported only with Java 8 and later (needs CLDR)
120 languages.put("km", PluralMode.MODE_NONE);
121 languages.put("lt", PluralMode.MODE_LT);
122 languages.put("nb", PluralMode.MODE_NOTONE);
123 languages.put("nl", PluralMode.MODE_NOTONE);
124 languages.put("pl", PluralMode.MODE_PL);
125 languages.put("pt", PluralMode.MODE_NOTONE);
126 languages.put("pt_BR", PluralMode.MODE_GREATERONE);
127 //languages.put("ro", PluralMode.MODE_RO);
128 languages.put("ru", PluralMode.MODE_RU);
129 languages.put("sk", PluralMode.MODE_SK);
130 //languages.put("sl", PluralMode.MODE_SL);
131 languages.put("sv", PluralMode.MODE_NOTONE);
132 //languages.put("tr", PluralMode.MODE_NONE);
133 languages.put("uk", PluralMode.MODE_RU);
134 languages.put("vi", PluralMode.MODE_NONE);
135 languages.put("zh_CN", PluralMode.MODE_NONE);
136 languages.put("zh_TW", PluralMode.MODE_NONE);
137 }
138
139 /**
140 * Translates some text for the current locale.
141 * These strings are collected by a script that runs on the source code files.
142 * After translation, the localizations are distributed with the main program.
143 * <br>
144 * For example, <code>tr("JOSM''s default value is ''{0}''.", val)</code>.
145 * <br>
146 * Use {@link #trn} for distinguishing singular from plural text, i.e.,
147 * do not use {@code tr(size == 1 ? "singular" : "plural")} nor
148 * {@code size == 1 ? tr("singular") : tr("plural")}
149 *
150 * @param text the text to translate.
151 * Must be a string literal. (No constants or local vars.)
152 * Can be broken over multiple lines.
153 * An apostrophe ' must be quoted by another apostrophe.
154 * @param objects the parameters for the string.
155 * Mark occurrences in {@code text} with <code>{0}</code>, <code>{1}</code>, ...
156 * @return the translated string.
157 * @see #trn
158 * @see #trc
159 * @see #trnc
160 */
161 public static String tr(String text, Object... objects) {
162 if (text == null) return null;
163 return MessageFormat.format(gettext(text, null), objects);
164 }
165
166 /**
167 * Translates some text in a context for the current locale.
168 * There can be different translations for the same text within different contexts.
169 *
170 * @param context string that helps translators to find an appropriate
171 * translation for {@code text}.
172 * @param text the text to translate.
173 * @return the translated string.
174 * @see #tr
175 * @see #trn
176 * @see #trnc
177 */
178 public static String trc(String context, String text) {
179 if (context == null)
180 return tr(text);
181 if (text == null)
182 return null;
183 return MessageFormat.format(gettext(text, context), (Object) null);
184 }
185
186 public static String trcLazy(String context, String text) {
187 if (context == null)
188 return tr(text);
189 if (text == null)
190 return null;
191 return MessageFormat.format(gettextLazy(text, context), (Object) null);
192 }
193
194 /**
195 * Marks a string for translation (such that a script can harvest
196 * the translatable strings from the source files).
197 *
198 * For example, <code>
199 * String[] options = new String[] {marktr("up"), marktr("down")};
200 * lbl.setText(tr(options[0]));</code>
201 * @param text the string to be marked for translation.
202 * @return {@code text} unmodified.
203 */
204 public static String marktr(String text) {
205 return text;
206 }
207
208 public static String marktrc(String context, String text) {
209 return text;
210 }
211
212 /**
213 * Translates some text for the current locale and distinguishes between
214 * {@code singularText} and {@code pluralText} depending on {@code n}.
215 * <br>
216 * For instance, {@code trn("There was an error!", "There were errors!", i)} or
217 * <code>trn("Found {0} error in {1}!", "Found {0} errors in {1}!", i, Integer.toString(i), url)</code>.
218 *
219 * @param singularText the singular text to translate.
220 * Must be a string literal. (No constants or local vars.)
221 * Can be broken over multiple lines.
222 * An apostrophe ' must be quoted by another apostrophe.
223 * @param pluralText the plural text to translate.
224 * Must be a string literal. (No constants or local vars.)
225 * Can be broken over multiple lines.
226 * An apostrophe ' must be quoted by another apostrophe.
227 * @param n a number to determine whether {@code singularText} or {@code pluralText} is used.
228 * @param objects the parameters for the string.
229 * Mark occurrences in {@code singularText} and {@code pluralText} with <code>{0}</code>, <code>{1}</code>, ...
230 * @return the translated string.
231 * @see #tr
232 * @see #trc
233 * @see #trnc
234 */
235 public static String trn(String singularText, String pluralText, long n, Object... objects) {
236 return MessageFormat.format(gettextn(singularText, pluralText, null, n), objects);
237 }
238
239 /**
240 * Translates some text in a context for the current locale and distinguishes between
241 * {@code singularText} and {@code pluralText} depending on {@code n}.
242 * There can be different translations for the same text within different contexts.
243 *
244 * @param context string that helps translators to find an appropriate
245 * translation for {@code text}.
246 * @param singularText the singular text to translate.
247 * Must be a string literal. (No constants or local vars.)
248 * Can be broken over multiple lines.
249 * An apostrophe ' must be quoted by another apostrophe.
250 * @param pluralText the plural text to translate.
251 * Must be a string literal. (No constants or local vars.)
252 * Can be broken over multiple lines.
253 * An apostrophe ' must be quoted by another apostrophe.
254 * @param n a number to determine whether {@code singularText} or {@code pluralText} is used.
255 * @param objects the parameters for the string.
256 * Mark occurrences in {@code singularText} and {@code pluralText} with <code>{0}</code>, <code>{1}</code>, ...
257 * @return the translated string.
258 * @see #tr
259 * @see #trc
260 * @see #trn
261 */
262 public static String trnc(String context, String singularText, String pluralText, long n, Object... objects) {
263 return MessageFormat.format(gettextn(singularText, pluralText, context, n), objects);
264 }
265
266 private static String gettext(String text, String ctx, boolean lazy) {
267 int i;
268 if (ctx == null && text.startsWith("_:") && (i = text.indexOf('\n')) >= 0) {
269 ctx = text.substring(2, i-1);
270 text = text.substring(i+1);
271 }
272 if (strings != null) {
273 String trans = strings.get(ctx == null ? text : "_:"+ctx+'\n'+text);
274 if (trans != null)
275 return trans;
276 }
277 if (pstrings != null) {
278 i = pluralEval(1);
279 String[] trans = pstrings.get(ctx == null ? text : "_:"+ctx+'\n'+text);
280 if (trans != null && trans.length > i)
281 return trans[i];
282 }
283 return lazy ? gettext(text, null) : text;
284 }
285
286 private static String gettext(String text, String ctx) {
287 return gettext(text, ctx, false);
288 }
289
290 /* try without context, when context try fails */
291 private static String gettextLazy(String text, String ctx) {
292 return gettext(text, ctx, true);
293 }
294
295 private static String gettextn(String text, String plural, String ctx, long num) {
296 int i;
297 if (ctx == null && text.startsWith("_:") && (i = text.indexOf('\n')) >= 0) {
298 ctx = text.substring(2, i-1);
299 text = text.substring(i+1);
300 }
301 if (pstrings != null) {
302 i = pluralEval(num);
303 String[] trans = pstrings.get(ctx == null ? text : "_:"+ctx+'\n'+text);
304 if (trans != null && trans.length > i)
305 return trans[i];
306 }
307
308 return num == 1 ? text : plural;
309 }
310
311 public static String escape(String msg) {
312 if (msg == null) return null;
313 return msg.replace("\'", "\'\'").replace("{", "\'{\'").replace("}", "\'}\'");
314 }
315
316 private static URL getTranslationFile(String lang) {
317 return I18n.class.getResource("/data/"+lang.replace('@', '-')+".lang");
318 }
319
320 /**
321 * Get a list of all available JOSM Translations.
322 * @return an array of locale objects.
323 */
324 public static Locale[] getAvailableTranslations() {
325 Collection<Locale> v = new ArrayList<>(languages.size());
326 if (getTranslationFile("en") != null) {
327 for (String loc : languages.keySet()) {
328 if (getTranslationFile(loc) != null) {
329 v.add(LanguageInfo.getLocale(loc));
330 }
331 }
332 }
333 v.add(Locale.ENGLISH);
334 Locale[] l = new Locale[v.size()];
335 l = v.toArray(l);
336 Arrays.sort(l, Comparator.comparing(Locale::toString));
337 return l;
338 }
339
340 /**
341 * Determines if a language exists for the given code.
342 * @param code The language code
343 * @return {@code true} if a language exists, {@code false} otherwise
344 */
345 public static boolean hasCode(String code) {
346 return languages.containsKey(code);
347 }
348
349 static void setupJavaLocaleProviders() {
350 // Look up SPI providers first (for JosmDecimalFormatSymbolsProvider).
351 // Enable CLDR locale provider on Java 8 to get additional languages, such as Khmer.
352 // http://docs.oracle.com/javase/8/docs/technotes/guides/intl/enhancements.8.html#cldr
353 // FIXME: This must be updated after we switch to Java 9.
354 // See https://docs.oracle.com/javase/9/docs/api/java/util/spi/LocaleServiceProvider.html
355 try {
356 // Don't call Utils.updateSystemProperty to avoid spurious log at startup
357 System.setProperty("java.locale.providers", "SPI,JRE,CLDR");
358 } catch (SecurityException e) {
359 // Don't call Logging class, it may not be fully initialized yet
360 System.err.println("Unable to set locale providers: " + e.getMessage());
361 }
362 }
363
364 /**
365 * I18n initialization.
366 */
367 public static void init() {
368 setupJavaLocaleProviders();
369
370 /* try initial language settings, may be changed later again */
371 if (!load(LanguageInfo.getJOSMLocaleCode())) {
372 Locale.setDefault(Locale.ENGLISH);
373 }
374 }
375
376 /**
377 * I18n initialization for plugins.
378 * @param source file path/name of the JAR or Zip file containing translation strings
379 * @since 4159
380 */
381 public static void addTexts(File source) {
382 if ("en".equals(loadedCode))
383 return;
384 final ZipEntry enfile = new ZipEntry("data/en.lang");
385 final ZipEntry langfile = new ZipEntry("data/"+loadedCode+".lang");
386 try (
387 ZipFile zipFile = new ZipFile(source, StandardCharsets.UTF_8);
388 InputStream orig = zipFile.getInputStream(enfile);
389 InputStream trans = zipFile.getInputStream(langfile)
390 ) {
391 if (orig != null && trans != null)
392 load(orig, trans, true);
393 } catch (IOException | InvalidPathException e) {
394 Logging.trace(e);
395 }
396 }
397
398 private static boolean load(String l) {
399 if ("en".equals(l) || "en_US".equals(l)) {
400 strings = null;
401 pstrings = null;
402 loadedCode = "en";
403 pluralMode = PluralMode.MODE_NOTONE;
404 return true;
405 }
406 URL en = getTranslationFile("en");
407 if (en == null)
408 return false;
409 URL tr = getTranslationFile(l);
410 if (tr == null || !languages.containsKey(l)) {
411 return false;
412 }
413 try (
414 InputStream enStream = Utils.openStream(en);
415 InputStream trStream = Utils.openStream(tr)
416 ) {
417 if (load(enStream, trStream, false)) {
418 pluralMode = languages.get(l);
419 loadedCode = l;
420 return true;
421 }
422 } catch (IOException e) {
423 // Ignore exception
424 Logging.trace(e);
425 }
426 return false;
427 }
428
429 private static boolean load(InputStream en, InputStream tr, boolean add) {
430 Map<String, String> s;
431 Map<String, String[]> p;
432 if (add) {
433 s = strings;
434 p = pstrings;
435 } else {
436 s = new HashMap<>();
437 p = new HashMap<>();
438 }
439 /* file format:
440 Files are always a group. English file and translated file must provide identical datasets.
441
442 for all single strings:
443 {
444 unsigned short (2 byte) stringlength
445 - length 0 indicates missing translation
446 - length 0xFFFE indicates translation equal to original, but otherwise is equal to length 0
447 string
448 }
449 unsigned short (2 byte) 0xFFFF (marks end of single strings)
450 for all multi strings:
451 {
452 unsigned char (1 byte) stringcount
453 - count 0 indicates missing translations
454 - count 0xFE indicates translations equal to original, but otherwise is equal to length 0
455 for stringcount
456 unsigned short (2 byte) stringlength
457 string
458 }
459 */
460 try {
461 InputStream ens = new BufferedInputStream(en);
462 InputStream trs = new BufferedInputStream(tr);
463 byte[] enlen = new byte[2];
464 byte[] trlen = new byte[2];
465 boolean multimode = false;
466 byte[] str = new byte[4096];
467 for (;;) {
468 if (multimode) {
469 int ennum = ens.read();
470 int trnum = trs.read();
471 if (trnum == 0xFE) /* marks identical string, handle equally to non-translated */
472 trnum = 0;
473 if ((ennum == -1 && trnum != -1) || (ennum != -1 && trnum == -1)) /* files do not match */
474 return false;
475 if (ennum == -1) {
476 break;
477 }
478 String[] enstrings = new String[ennum];
479 for (int i = 0; i < ennum; ++i) {
480 int val = ens.read(enlen);
481 if (val != 2) /* file corrupt */
482 return false;
483 val = (enlen[0] < 0 ? 256+enlen[0] : enlen[0])*256+(enlen[1] < 0 ? 256+enlen[1] : enlen[1]);
484 if (val > str.length) {
485 str = new byte[val];
486 }
487 int rval = ens.read(str, 0, val);
488 if (rval != val) /* file corrupt */
489 return false;
490 enstrings[i] = new String(str, 0, val, StandardCharsets.UTF_8);
491 }
492 String[] trstrings = new String[trnum];
493 for (int i = 0; i < trnum; ++i) {
494 int val = trs.read(trlen);
495 if (val != 2) /* file corrupt */
496 return false;
497 val = (trlen[0] < 0 ? 256+trlen[0] : trlen[0])*256+(trlen[1] < 0 ? 256+trlen[1] : trlen[1]);
498 if (val > str.length) {
499 str = new byte[val];
500 }
501 int rval = trs.read(str, 0, val);
502 if (rval != val) /* file corrupt */
503 return false;
504 trstrings[i] = new String(str, 0, val, StandardCharsets.UTF_8);
505 }
506 if (trnum > 0 && !p.containsKey(enstrings[0])) {
507 p.put(enstrings[0], trstrings);
508 }
509 } else {
510 int enval = ens.read(enlen);
511 int trval = trs.read(trlen);
512 if (enval != trval) /* files do not match */
513 return false;
514 if (enval == -1) {
515 break;
516 }
517 if (enval != 2) /* files corrupt */
518 return false;
519 enval = (enlen[0] < 0 ? 256+enlen[0] : enlen[0])*256+(enlen[1] < 0 ? 256+enlen[1] : enlen[1]);
520 trval = (trlen[0] < 0 ? 256+trlen[0] : trlen[0])*256+(trlen[1] < 0 ? 256+trlen[1] : trlen[1]);
521 if (trval == 0xFFFE) /* marks identical string, handle equally to non-translated */
522 trval = 0;
523 if (enval == 0xFFFF) {
524 multimode = true;
525 if (trval != 0xFFFF) /* files do not match */
526 return false;
527 } else {
528 if (enval > str.length) {
529 str = new byte[enval];
530 }
531 if (trval > str.length) {
532 str = new byte[trval];
533 }
534 int val = ens.read(str, 0, enval);
535 if (val != enval) /* file corrupt */
536 return false;
537 String enstr = new String(str, 0, enval, StandardCharsets.UTF_8);
538 if (trval != 0) {
539 val = trs.read(str, 0, trval);
540 if (val != trval) /* file corrupt */
541 return false;
542 String trstr = new String(str, 0, trval, StandardCharsets.UTF_8);
543 if (!s.containsKey(enstr))
544 s.put(enstr, trstr);
545 }
546 }
547 }
548 }
549 } catch (IOException e) {
550 Logging.trace(e);
551 return false;
552 }
553 if (!s.isEmpty()) {
554 strings = s;
555 pstrings = p;
556 return true;
557 }
558 return false;
559 }
560
561 /**
562 * Sets the default locale (see {@link Locale#setDefault(Locale)} to the local
563 * given by <code>localName</code>.
564 *
565 * Ignored if localeName is null. If the locale with name <code>localName</code>
566 * isn't found the default local is set to <code>en</code> (english).
567 *
568 * @param localeName the locale name. Ignored if null.
569 */
570 public static void set(String localeName) {
571 if (localeName != null) {
572 Locale l = LanguageInfo.getLocale(localeName);
573 if (load(LanguageInfo.getJOSMLocaleCode(l))) {
574 Locale.setDefault(l);
575 } else {
576 if (!"en".equals(l.getLanguage())) {
577 Logging.info(tr("Unable to find translation for the locale {0}. Reverting to {1}.",
578 LanguageInfo.getDisplayName(l), LanguageInfo.getDisplayName(Locale.getDefault())));
579 } else {
580 strings = null;
581 pstrings = null;
582 }
583 }
584 }
585 }
586
587 private static int pluralEval(long n) {
588 switch(pluralMode) {
589 case MODE_NOTONE: /* bg, da, de, el, en, en_GB, es, et, eu, fi, gl, is, it, iw_IL, nb, nl, sv */
590 return (n != 1) ? 1 : 0;
591 case MODE_NONE: /* id, vi, ja, km, tr, zh_CN, zh_TW */
592 return 0;
593 case MODE_GREATERONE: /* fr, pt_BR */
594 return (n > 1) ? 1 : 0;
595 case MODE_CS:
596 return (n == 1) ? 0 : (((n >= 2) && (n <= 4)) ? 1 : 2);
597 //case MODE_AR:
598 // return ((n == 0) ? 0 : ((n == 1) ? 1 : ((n == 2) ? 2 : ((((n % 100) >= 3)
599 // && ((n % 100) <= 10)) ? 3 : ((((n % 100) >= 11) && ((n % 100) <= 99)) ? 4 : 5)))));
600 case MODE_PL:
601 return (n == 1) ? 0 : (((((n % 10) >= 2) && ((n % 10) <= 4))
602 && (((n % 100) < 10) || ((n % 100) >= 20))) ? 1 : 2);
603 //case MODE_RO:
604 // return ((n == 1) ? 0 : ((((n % 100) > 19) || (((n % 100) == 0) && (n != 0))) ? 2 : 1));
605 case MODE_LT:
606 return ((n % 10) == 1) && ((n % 100) != 11) ? 0 : (((n % 10) >= 2)
607 && (((n % 100) < 10) || ((n % 100) >= 20)) ? 1 : 2);
608 case MODE_RU:
609 return (((n % 10) == 1) && ((n % 100) != 11)) ? 0 : (((((n % 10) >= 2)
610 && ((n % 10) <= 4)) && (((n % 100) < 10) || ((n % 100) >= 20))) ? 1 : 2);
611 case MODE_SK:
612 return (n == 1) ? 1 : (((n >= 2) && (n <= 4)) ? 2 : 0);
613 //case MODE_SL:
614 // return (((n % 100) == 1) ? 1 : (((n % 100) == 2) ? 2 : ((((n % 100) == 3)
615 // || ((n % 100) == 4)) ? 3 : 0)));
616 }
617 return 0;
618 }
619
620 /**
621 * Returns the map of singular translations.
622 * @return the map of singular translations.
623 * @since 13761
624 */
625 public static Map<String, String> getSingularTranslations() {
626 return new HashMap<>(strings);
627 }
628
629 /**
630 * Returns the map of plural translations.
631 * @return the map of plural translations.
632 * @since 13761
633 */
634 public static Map<String, String[]> getPluralTranslations() {
635 return new HashMap<>(pstrings);
636 }
637}
Note: See TracBrowser for help on using the repository browser.