From 801b799422a465f34704b1d84c38605ed44aef9f Mon Sep 17 00:00:00 2001 From: serso Date: Sun, 19 Jun 2016 10:57:10 +0200 Subject: [PATCH] Add "languages" command-line argument --- .../org/solovyev/android/translations/Android.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/translations/src/main/java/org/solovyev/android/translations/Android.java b/translations/src/main/java/org/solovyev/android/translations/Android.java index d42000cd..e01ad88f 100644 --- a/translations/src/main/java/org/solovyev/android/translations/Android.java +++ b/translations/src/main/java/org/solovyev/android/translations/Android.java @@ -5,6 +5,7 @@ import org.apache.http.util.TextUtils; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class Android { @@ -15,6 +16,7 @@ public class Android { options.addOption(Option.builder("project").hasArg().desc("Local location of Android project").build()); options.addOption(Option.builder("resources").hasArg().desc("String identifiers to be copied").build()); options.addOption(Option.builder("output").hasArg().desc("Output folder").required().build()); + options.addOption(Option.builder("languages").hasArg().desc("Comma-separated list of languages for translation").required().build()); final CommandLineParser parser = new DefaultParser(); final CommandLine commandLine = parser.parse(options, args); @@ -50,6 +52,10 @@ public class Android { projectsLinks = null; } + final List languageLocales = new ArrayList<>(); + languageLocales.addAll(Arrays.asList(commandLine.getOptionValue("languages").split(","))); + languageLocales.add(""); + final File outDir = new File(commandLine.getOptionValue("output")); Utils.delete(outDir); final File outResDir = new File(outDir, "res"); @@ -62,7 +68,7 @@ public class Android { for (int i = 0; i < projects.length; i++) { final File project = projects[i]; final List projectLinks = projectsLinks[i]; - translate(outResDir, "other" + (i == 0 ? "" : i), new TranslationDef(project, projectLinks)); + translate(outResDir, languageLocales, "other" + (i == 0 ? "" : i), new TranslationDef(project, projectLinks)); } } } @@ -74,9 +80,7 @@ public class Android { return prefix + "_"; } - private static void translate(File outDir, String outPostfix, TranslationDef... translationDefs) throws Exception { - List languageLocales = new ArrayList<>(Utils.languageLocales); - languageLocales.add(""); + private static void translate(File outDir, List languageLocales, String outPostfix, TranslationDef... translationDefs) throws Exception { for (String languageLocale : languageLocales) { Resources translations = new Resources(); for (TranslationDef def : translationDefs) {