1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import java.text.MessageFormat;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Internationalisation support.
|
---|
8 | *
|
---|
9 | * @author Immanuel.Scholz
|
---|
10 | */
|
---|
11 | public class I18n {
|
---|
12 | /**
|
---|
13 | * Set by MainApplication. Changes here later will probably mess up everything, because
|
---|
14 | * many strings are already loaded.
|
---|
15 | */
|
---|
16 | public static org.xnap.commons.i18n.I18n i18n;
|
---|
17 |
|
---|
18 | public static String tr(String text, Object... objects) {
|
---|
19 | if (i18n == null)
|
---|
20 | return MessageFormat.format(text, objects);
|
---|
21 | return i18n.tr(text, objects);
|
---|
22 | }
|
---|
23 |
|
---|
24 | public static String tr(String text) {
|
---|
25 | if (i18n == null)
|
---|
26 | return text;
|
---|
27 | return i18n.tr(text);
|
---|
28 | }
|
---|
29 |
|
---|
30 | public static String trn(String text, String pluralText, long n, Object... objects) {
|
---|
31 | if (i18n == null)
|
---|
32 | return n == 1 ? tr(text, objects) : tr(pluralText, objects);
|
---|
33 | return i18n.trn(text, pluralText, n, objects);
|
---|
34 | }
|
---|
35 |
|
---|
36 | public static String trn(String text, String pluralText, long n) {
|
---|
37 | if (i18n == null)
|
---|
38 | return n == 1 ? tr(text) : tr(pluralText);
|
---|
39 | return i18n.trn(text, pluralText, n);
|
---|
40 | }
|
---|
41 | }
|
---|