Ignore:
Timestamp:
2015-02-21T15:27:40+01:00 (10 years ago)
Author:
stoecker
Message:

proper handling of language infor for maps name and description

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r8067 r8091  
    2828import org.openstreetmap.josm.tools.CheckParameterUtil;
    2929import org.openstreetmap.josm.tools.ImageProvider;
     30import org.openstreetmap.josm.tools.LanguageInfo;
    3031
    3132/**
     
    152153    /** name of the imagery entry (gets translated by josm usually) */
    153154    private String name;
    154     /** original name of the imagery entry in case of translation call */
     155    /** original name of the imagery entry in case of translation call, for multiple languages English when possible */
    155156    private String origName;
     157    /** (original) language of the translated name entry */
     158    private String langName;
    156159    /** id for this imagery entry, optional at the moment */
    157160    private String id;
     
    166169    private ImageryBounds bounds = null;
    167170    private List<String> serverProjections;
     171    /** description of the imagery entry, should contain notes what type of data it is */
    168172    private String description;
     173    /** language of the description entry, "" for tr() result */
     174    private String langDescription;
    169175    private String attributionText;
    170176    private String attributionLinkURL;
     
    686692
    687693    /**
    688      * Sets the entry name and translates it.
     694     * Sets the entry name and handle translation.
     695     * @param name The used language
    689696     * @param name The entry name
    690      * @since 6968
    691      */
    692     public void setTranslatedName(String name) {
    693         this.name = tr(name);
    694         this.origName = name;
     697     * @since 8091
     698     */
     699    public void setName(String language, String name) {
     700        boolean isdefault = LanguageInfo.getJOSMLocaleCode(null).equals(language);
     701        if(LanguageInfo.isBetterLanguage(langName, language)) {
     702            this.name = isdefault ? tr(name) : name;
     703            this.langName = language;
     704        }
     705        if(origName == null || isdefault) {
     706            this.origName = name;
     707        }
    695708    }
    696709
     
    791804    /**
    792805     * Sets the description text when existing.
     806     * @param name The used language
    793807     * @param description the imagery description text
    794      * @since 8065
    795      */
    796     public void setDescription(String description) {
    797         this.description = description;
     808     * @since 8091
     809     */
     810    public void setDescription(String language, String description) {
     811        boolean isdefault = LanguageInfo.getJOSMLocaleCode(null).equals(language);
     812        if(LanguageInfo.isBetterLanguage(langDescription, language)) {
     813            this.description = isdefault ? tr(description) : description;
     814            this.langDescription = language;
     815        }
    798816    }
    799817
Note: See TracChangeset for help on using the changeset viewer.