Changeset 1541 in josm for trunk


Ignore:
Timestamp:
2009-04-20T13:01:04+02:00 (16 years ago)
Author:
framm
Message:

support translation of extra API error messages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r1530 r1541  
    2121import java.util.Collection;
    2222import java.util.Properties;
     23import java.util.HashMap;
    2324import java.util.StringTokenizer;
    2425
     
    7879     */
    7980    private boolean initialized = false;
     81
     82    /**
     83     * list of server error messages (as transported in the Error: header) and their translations.
     84     */
     85    public static final HashMap<String,String> serverErrorTranslations;
     86
     87    static {
     88        serverErrorTranslations = new HashMap<String,String>();
     89        serverErrorTranslations.put("Database offline for maintenance",
     90            tr("Database offline for maintenance"));
     91        serverErrorTranslations.put("You must make your edits public to upload new data",
     92            tr("You must make your edits public to upload new data"));
     93        // FIXME there is one additional server error message that goes
     94        // "You requested too many nodes (limit is #{APP_CONFIG['max_number_of_nodes']}). Either request a smaller area, or use planet.osm"
     95        // but we would have to switch this mechanism to using regular expressions if we wanted to translate that...
     96    }
    8097   
    8198    private StringWriter swriter = new StringWriter();
     
    410427                if (activeConnection.getHeaderField("Error") != null) {
    411428                    statusMessage.append(": ");
    412                     statusMessage.append(activeConnection.getHeaderField("Error"));
     429                    String er = activeConnection.getHeaderField("Error");
     430                    if (serverErrorTranslations.containsKey(er)) er = serverErrorTranslations.get(er);
     431                    statusMessage.append(er);
    413432                }
    414433                activeConnection.disconnect();
Note: See TracChangeset for help on using the changeset viewer.