Changeset 2230 in josm


Ignore:
Timestamp:
Oct 3, 2009 1:56:26 PM (4 years ago)
Author:
stoecker
Message:

added translation context support also for presets

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/presets/presets.xml

    r2207 r2230  
    3535  text: fixed label to display 
    3636  values: comma seperated list of values 
     37  display_values: comma seperated list of values to be displayed instead of the 
     38                  database values, order and number must be equal to values 
    3739  default: default string to display 
    3840  delete_if_empty: true/false 
     
    5355 
    5456See also http://josm.openstreetmap.de/wiki/TaggingPresets. 
     57 
     58The fields "name", "text", "display_values" may also be localized (e.g. de.name). 
     59When translations of equal words but different meanings may conflict, a translation 
     60context should be specified. Use "name_conext", "text_context" or "values_context" 
     61for this. The context should be a meaningful short description to help translators. 
     62 
     63In JOSM internally all "name", "text" and "display_values" are translated when 
     64no specific translation has been given in XML file. When no "display_values" 
     65are supplied, then "values" will be treated as "display_values" and translated instead. 
    5566--> 
    5667<annotations> 
     
    13671378            <text key="name" text="Name" default="" delete_if_empty="true" /> 
    13681379        </item> 
    1369         <item name="Station" icon="presets/aerialway_station.png" type="node,closedway"> 
     1380        <item name="Station" name_context="aerialway" icon="presets/aerialway_station.png" type="node,closedway"> 
    13701381            <link href="http://wiki.openstreetmap.org/wiki/Proposed_features/Piste_Maps" /> 
    1371             <label text="Edit Station" /> 
     1382            <label text="Edit Station" text_context="aerialway" /> 
    13721383            <key key="aerialway" value="station" /> 
    13731384            <text key="name" text="Name" default="" delete_if_empty="true" /> 
     
    14621473    </group> <!-- Bicycle --> 
    14631474    <group name="Public Transport" icon="presets/bus.png"> 
    1464         <item name="Station" icon="presets/station.png" type="node,closedway"> 
     1475        <item name="Station" name_context="railway" icon="presets/station.png" type="node,closedway"> 
    14651476            <link href="http://wiki.openstreetmap.org/wiki/Tag:railway=station" 
    14661477                  de.href="http://wiki.openstreetmap.org/wiki/DE:Tag:railway=station" /> 
    1467             <label text="Edit Station" /> 
     1478            <label text="Edit Station" text_context="railway" /> 
    14681479            <space /> 
    14691480            <key key="railway" value="station" /> 
  • 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.