Changeset 13507 in josm for trunk/src


Ignore:
Timestamp:
2018-03-04T22:09:01+01:00 (6 years ago)
Author:
stoecker
Message:

see #11392 - take new shorter I18n implementation also for plugins

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

Legend:

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

    r13502 r13507  
    745745             Reader reader = new BufferedReader(UTFInputStreamReader.create(s))) {
    746746            if (zip != null)
    747                 I18n.addTextsZip(cache.getFile());
     747                I18n.addTexts(cache.getFile());
    748748            result = TagCheck.readMapCSS(reader);
    749749            checks.remove(url);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r13506 r13507  
    516516            zipFile = new ZipFile(file, StandardCharsets.UTF_8);
    517517            zipIcons = file;
    518             I18n.addTextsZip(zipIcons);
     518            I18n.addTexts(zipIcons);
    519519            ZipEntry zipEntry = zipFile.getEntry(zipEntryPath);
    520520            return zipFile.getInputStream(zipEntry);
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReader.java

    r13506 r13507  
    344344            if (zip != null) {
    345345                zipIcons = cf.getFile();
    346                 I18n.addTextsZip(zipIcons);
     346                I18n.addTexts(zipIcons);
    347347            }
    348348            try (InputStreamReader r = UTFInputStreamReader.create(zip == null ? cf.getInputStream() : zip)) {
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r13503 r13507  
    2020import java.util.Locale;
    2121import java.util.Map;
    22 import java.util.jar.JarInputStream;
    2322import java.util.zip.ZipEntry;
    2423import java.util.zip.ZipFile;
     
    370369    /**
    371370     * I18n initialization for plugins.
    372      * @param source file path/name of the JAR file containing translation strings
     371     * @param source file path/name of the JAR or Zip file containing translation strings
    373372     * @since 4159
    374373     */
    375374    public static void addTexts(File source) {
    376         if ("en".equals(loadedCode))
    377             return;
    378         final String enfile = "data/en.lang";
    379         final String langfile = "data/"+loadedCode+".lang";
    380         try (
    381             InputStream fis = Files.newInputStream(source.toPath());
    382             JarInputStream jar = new JarInputStream(fis)
    383         ) {
    384             ZipEntry e;
    385             boolean found = false;
    386             while (!found && (e = jar.getNextEntry()) != null) {
    387                 String name = e.getName();
    388                 if (enfile.equals(name))
    389                     found = true;
    390             }
    391             if (found) {
    392                 try (
    393                     InputStream fisTrans = Files.newInputStream(source.toPath());
    394                     JarInputStream jarTrans = new JarInputStream(fisTrans)
    395                 ) {
    396                     found = false;
    397                     while (!found && (e = jarTrans.getNextEntry()) != null) {
    398                         String name = e.getName();
    399                         if (name.equals(langfile))
    400                             found = true;
    401                     }
    402                     if (found)
    403                         load(jar, jarTrans, true);
    404                 }
    405             }
    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 13502
    415      */
    416     public static void addTextsZip(File source) {
    417375        if ("en".equals(loadedCode))
    418376            return;
Note: See TracChangeset for help on using the changeset viewer.