Ignore:
Timestamp:
2008-07-05T14:12:34+02:00 (18 years ago)
Author:
stoecker
Message:

finished XML based translations of presets fixes #960
correct bounding box illegal access fixes #1044
do no longer modify objects when unnessesary (can result in 0 objects
modified in Undo :-)
correct typo fixes #730
some I18N corrections

File:
1 edited

Legend:

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

    r627 r679  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.tools;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.io.Reader;
     
    2830public class XmlObjectParser implements Iterable<Object> {
    2931
     32        public static final String lang = tr("En:").toLowerCase();
    3033        public static class Uniform<T> implements Iterable<T>{
    3134                private Iterator<Object> iterator;
     
    104107                                Field f = null;
    105108                                try {
    106                         f = c.getClass().getField(fieldName);
    107                 } catch (NoSuchFieldException e) {
    108                 }
     109                                        f = c.getClass().getField(fieldName);
     110                                } catch (NoSuchFieldException e) {
     111                                        if(fieldName.startsWith(lang))
     112                                        {
     113                                                String locfieldName = "locale_" +
     114                                                fieldName.substring(lang.length());
     115                                                try {
     116                                                        f = c.getClass().getField(locfieldName);
     117                                                } catch (NoSuchFieldException ex) {
     118                                                }
     119                                        }
     120                                }
    109121                                if (f != null && Modifier.isPublic(f.getModifiers()))
    110122                                        f.set(c, getValueForClass(f.getType(), value));
    111123                                else {
    112                                         fieldName = "set" + fieldName.substring(0,1).toUpperCase() + fieldName.substring(1);
     124                                        if(fieldName.startsWith(lang))
     125                                        {
     126                                                int l = lang.length();
     127                                                fieldName = "set" + fieldName.substring(l,l+1).toUpperCase() + fieldName.substring(l+1);
     128                                        }
     129                                        else
     130                                        {
     131                                                fieldName = "set" + fieldName.substring(0,1).toUpperCase() + fieldName.substring(1);
     132                                        }
    113133                                        Method[] methods = c.getClass().getDeclaredMethods();
    114134                                        for (Method m : methods) {
Note: See TracChangeset for help on using the changeset viewer.