Ignore:
Timestamp:
2009-09-20T22:17:04+02:00 (15 years ago)
Author:
stoecker
Message:

added context handling for translated strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r2017 r2174  
    3131    public static final String tr(String text, Object... objects) {
    3232        if (i18n == null)
    33             return MessageFormat.format(text, objects);
    34         return i18n.tr(text, objects);
     33            return filter(MessageFormat.format(text, objects));
     34        return filter(i18n.tr(text, objects));
    3535    }
    3636
    3737    public static final String tr(String text) {
    3838        if (i18n == null)
    39             return text;
    40         return i18n.tr(text);
     39            return filter(text);
     40        return filter(i18n.tr(text));
    4141    }
    4242
     
    4747    public static final String trn(String text, String pluralText, long n, Object... objects) {
    4848        if (i18n == null)
    49             return n == 1 ? tr(text, objects) : tr(pluralText, objects);
    50         return i18n.trn(text, pluralText, n, objects);
     49            return filter(n == 1 ? tr(text, objects) : tr(pluralText, objects));
     50        return filter(i18n.trn(text, pluralText, n, objects));
    5151    }
    5252
    5353    public static final String trn(String text, String pluralText, long n) {
    5454        if (i18n == null)
    55             return n == 1 ? tr(text) : tr(pluralText);
    56         return i18n.trn(text, pluralText, n);
     55            return filter(n == 1 ? tr(text) : tr(pluralText));
     56        return filter(i18n.trn(text, pluralText, n));
     57    }
     58
     59    public static final String filter(String text)
     60    {
     61        int i;
     62        if(text.startsWith("~") && (i = text.indexOf(":")) >= 0)
     63            return text.substring(i+1);
     64        return text;
    5765    }
    5866
Note: See TracChangeset for help on using the changeset viewer.