Changeset 13502 in josm


Ignore:
Timestamp:
2018-03-04T18:16:19+01:00 (9 months ago)
Author:
stoecker
Message:

see #11392 - first try to add I18n for external Validators (style, presets still missing)

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r13314 r13502  
    6767import org.openstreetmap.josm.spi.preferences.Config;
    6868import org.openstreetmap.josm.tools.CheckParameterUtil;
     69import org.openstreetmap.josm.tools.I18n;
    6970import org.openstreetmap.josm.tools.Logging;
    7071import org.openstreetmap.josm.tools.MultiMap;
     
    743744             InputStream s = zip != null ? zip : cache.getInputStream();
    744745             Reader reader = new BufferedReader(UTFInputStreamReader.create(s))) {
     746            if (zip != null)
     747                I18n.addTextsZip(cache.getFile());
    745748            result = TagCheck.readMapCSS(reader);
    746749            checks.remove(url);
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r13493 r13502  
    2222import java.util.jar.JarInputStream;
    2323import java.util.zip.ZipEntry;
     24import java.util.zip.ZipFile;
    2425
    2526/**
     
    367368    }
    368369
     370    /**
     371     * I18n initialization for plugins.
     372     * @param source file path/name of the JAR file containing translation strings
     373     * @since 4159
     374     */
    369375    public static void addTexts(File source) {
    370376        if ("en".equals(loadedCode))
     
    398404                }
    399405            }
     406        } catch (IOException | InvalidPathException e) {
     407            Logging.trace(e);
     408        }
     409    }
     410
     411    /**
     412     * I18n initialization for Zip based resources.
     413     * @param source input Zip source
     414     * @since xxx
     415     */
     416    public static void addTextsZip(File source) {
     417        if ("en".equals(loadedCode))
     418            return;
     419        final ZipEntry enfile = new ZipEntry("data/en.lang");
     420        final ZipEntry langfile = new ZipEntry("data/"+loadedCode+".lang");
     421        try (
     422            ZipFile zipFile = new ZipFile(source, StandardCharsets.UTF_8);
     423            InputStream orig = zipFile.getInputStream(enfile);
     424            InputStream trans = zipFile.getInputStream(langfile);
     425        ) {
     426            if (orig != null && trans != null)
     427                load(orig, trans, true);
    400428        } catch (IOException | InvalidPathException e) {
    401429            Logging.trace(e);
Note: See TracChangeset for help on using the changeset viewer.