Ignore:
Timestamp:
2009-10-03T13:56:26+02:00 (15 years ago)
Author:
stoecker
Message:

added translation context support also for presets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r2193 r2230  
    44import static org.openstreetmap.josm.tools.I18n.marktr;
    55import static org.openstreetmap.josm.tools.I18n.tr;
     6import static org.openstreetmap.josm.tools.I18n.trc;
    67import static org.openstreetmap.josm.tools.I18n.trn;
    78
     
    6869    public TaggingPresetMenu group = null;
    6970    public String name;
     71    public String name_context;
    7072    public String locale_name;
    7173
     
    141143        public String text;
    142144        public String locale_text;
     145        public String text_context;
    143146        public String default_;
    144147        public String originalValue;
     
    178181            }
    179182            if(locale_text == null) {
    180                 locale_text = tr(text);
     183                if(text_context != null)
     184                    locale_text = trc(text_context, text);
     185                else
     186                    locale_text = tr(text);
    181187            }
    182188            p.add(new JLabel(locale_text+":"), GBC.std().insets(0,0,10,0));
     
    209215        public String key;
    210216        public String text;
     217        public String text_context;
    211218        public String locale_text;
    212219        public boolean default_ = false; // only used for tagless objects
     
    224231
    225232            if(locale_text == null) {
    226                 locale_text = tr(text);
     233                if(text_context != null)
     234                    locale_text = trc(text_context, text);
     235                else
     236                    locale_text = tr(text);
    227237            }
    228238
     
    287297        public String key;
    288298        public String text;
     299        public String text_context;
    289300        public String locale_text;
    290301        public String values;
     302        public String values_context;
    291303        public String display_values;
    292304        public String locale_display_values;
     
    321333            }
    322334            for (int i=0; i<value_array.length; i++) {
    323                 lhm.put(value_array[i],
    324                         (locale_display_values == null) ?
    325                                 tr(display_array[i]) : display_array[i]);
     335                lhm.put(value_array[i], (locale_display_values == null)
     336                ? (values_context == null ? tr(display_array[i])
     337                : tr(values_context, display_array[i])) : display_array[i]);
    326338            }
    327339            if(!usage.unused()){
     
    365377
    366378            if(locale_text == null) {
    367                 locale_text = tr(text);
     379                if(text_context != null)
     380                    locale_text = trc(text_context, text);
     381                else
     382                    locale_text = tr(text);
    368383            }
    369384            p.add(new JLabel(locale_text+":"), GBC.std().insets(0,0,10,0));
     
    407422    public static class Label extends Item {
    408423        public String text;
     424        public String text_context;
    409425        public String locale_text;
    410426
    411427        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
    412428            if(locale_text == null) {
    413                 locale_text = tr(text);
     429                if(text_context != null)
     430                    locale_text = trc(text_context, text);
     431                else
     432                    locale_text = tr(text);
    414433            }
    415434            p.add(new JLabel(locale_text), GBC.eol());
     
    422441        public String href;
    423442        public String text;
     443        public String text_context;
    424444        public String locale_text;
    425445        public String locale_href;
     
    427447        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
    428448            if(locale_text == null) {
    429                 locale_text = text == null ? tr("More information about this feature") : tr(text);
     449                if(text == null)
     450                    locale_text = tr("More information about this feature");
     451                if(text_context != null)
     452                    locale_text = trc(text_context, text);
     453                else
     454                    locale_text = tr(text);
    430455            }
    431456            String url = locale_href;
     
    500525    public String getLocaleName() {
    501526        if(locale_name == null) {
    502             locale_name = tr(name);
     527            if(name_context != null)
     528                locale_name = trc(name_context, name);
     529            else
     530                locale_name = tr(name);
    503531        }
    504532        return locale_name;
Note: See TracChangeset for help on using the changeset viewer.