More imported strings

This commit is contained in:
serso 2016-02-26 22:52:33 +01:00
parent e46207b48b
commit 922b9d7d2a
19 changed files with 163 additions and 39 deletions

View File

@ -13,4 +13,9 @@
<string name="cpp_create">إنشاء</string>
<string name="cpp_close">إغلاق</string>
<string name="cpp_switch">تبديل</string>
<string name="cpp_edit">تعديل</string>
<string name="cpp_delete">حذف</string>
<string name="cpp_save">تم</string>
<string name="cpp_cancel">إلغاء</string>
<string name="cpp_description">الوصف</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Vytvořit</string>
<string name="cpp_close">Zavřít</string>
<string name="cpp_switch">Přepnout</string>
<string name="cpp_edit">Upravit</string>
<string name="cpp_delete">Smazat</string>
<string name="cpp_save">Hotovo</string>
<string name="cpp_cancel">Zrušit</string>
<string name="cpp_description">Popis</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Erstellen</string>
<string name="cpp_close">Schließen</string>
<string name="cpp_switch">Wechseln</string>
<string name="cpp_edit">Bearbeiten</string>
<string name="cpp_delete">Löschen</string>
<string name="cpp_save">Fertig</string>
<string name="cpp_cancel">Abbrechen</string>
<string name="cpp_description">Beschreibung</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Crear</string>
<string name="cpp_close">Cerrar</string>
<string name="cpp_switch">Cambiar</string>
<string name="cpp_edit">Editar</string>
<string name="cpp_delete">Eliminar</string>
<string name="cpp_save">Listo</string>
<string name="cpp_cancel">Cancelar</string>
<string name="cpp_description">Descripción</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Luo</string>
<string name="cpp_close">Sulje</string>
<string name="cpp_switch">Vaihda</string>
<string name="cpp_edit">Muokkaa</string>
<string name="cpp_delete">Poista</string>
<string name="cpp_save">Valmis</string>
<string name="cpp_cancel">Peruuta</string>
<string name="cpp_description">Kuvaus</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Créer</string>
<string name="cpp_close">Fermer</string>
<string name="cpp_switch">Changer</string>
<string name="cpp_edit">Modifier</string>
<string name="cpp_delete">Supprimer</string>
<string name="cpp_save">OK</string>
<string name="cpp_cancel">Annuler</string>
<string name="cpp_description">Description</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Crea</string>
<string name="cpp_close">Chiudi</string>
<string name="cpp_switch">Cambia</string>
<string name="cpp_edit">Modifica</string>
<string name="cpp_delete">Elimina</string>
<string name="cpp_save">Salva</string>
<string name="cpp_cancel">Annulla</string>
<string name="cpp_description">Descrizione</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">作成</string>
<string name="cpp_close">閉じる</string>
<string name="cpp_switch">切り替え</string>
<string name="cpp_edit">編集</string>
<string name="cpp_delete">削除</string>
<string name="cpp_save">完了</string>
<string name="cpp_cancel">キャンセル</string>
<string name="cpp_description">説明</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Aanmaken</string>
<string name="cpp_close">Sluiten</string>
<string name="cpp_switch">Overschakelen</string>
<string name="cpp_edit">Bewerken</string>
<string name="cpp_delete">Verwijderen</string>
<string name="cpp_save">Gereed</string>
<string name="cpp_cancel">Annuleren</string>
<string name="cpp_description">Beschrijving</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Utwórz</string>
<string name="cpp_close">Zamknij</string>
<string name="cpp_switch">Przełącz</string>
<string name="cpp_edit">Edytuj</string>
<string name="cpp_delete">Usuń</string>
<string name="cpp_save">Gotowe</string>
<string name="cpp_cancel">Anuluj</string>
<string name="cpp_description">Opis</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Criar</string>
<string name="cpp_close">Fechar</string>
<string name="cpp_switch">Alternar</string>
<string name="cpp_edit">Editar</string>
<string name="cpp_delete">Excluir</string>
<string name="cpp_save">Concluído</string>
<string name="cpp_cancel">Cancelar</string>
<string name="cpp_description">Descrição</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Criar</string>
<string name="cpp_close">Fechar</string>
<string name="cpp_switch">Alternar</string>
<string name="cpp_edit">Editar</string>
<string name="cpp_delete">Eliminar</string>
<string name="cpp_save">Concluído</string>
<string name="cpp_cancel">Cancelar</string>
<string name="cpp_description">Descrição</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Создать</string>
<string name="cpp_close">Закрыть</string>
<string name="cpp_switch">Сменить аккаунт</string>
<string name="cpp_edit">Изменить</string>
<string name="cpp_delete">Удалить</string>
<string name="cpp_save">Готово</string>
<string name="cpp_cancel">Отмена</string>
<string name="cpp_description">Описание</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Oluştur</string>
<string name="cpp_close">Kapat</string>
<string name="cpp_switch">Değiştir</string>
<string name="cpp_edit">Düzenle</string>
<string name="cpp_delete">Sil</string>
<string name="cpp_save">Bitti</string>
<string name="cpp_cancel">İptal</string>
<string name="cpp_description">ıklama</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Tạo</string>
<string name="cpp_close">Đóng</string>
<string name="cpp_switch">Chuyển đổi</string>
<string name="cpp_edit">Chỉnh sửa</string>
<string name="cpp_delete">Xóa</string>
<string name="cpp_save">Xong</string>
<string name="cpp_cancel">Hủy</string>
<string name="cpp_description">Mô tả</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">创建</string>
<string name="cpp_close">关闭</string>
<string name="cpp_switch">切换</string>
<string name="cpp_edit">编辑</string>
<string name="cpp_delete">删除</string>
<string name="cpp_save">完成</string>
<string name="cpp_cancel">取消</string>
<string name="cpp_description">说明</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">建立</string>
<string name="cpp_close">關閉</string>
<string name="cpp_switch">切換</string>
<string name="cpp_edit">編輯</string>
<string name="cpp_delete">刪除</string>
<string name="cpp_save">完成</string>
<string name="cpp_cancel">取消</string>
<string name="cpp_description">說明</string>
</resources>

View File

@ -13,4 +13,9 @@
<string name="cpp_create">Create</string>
<string name="cpp_close">Close</string>
<string name="cpp_switch">Switch</string>
<string name="cpp_edit">Edit</string>
<string name="cpp_delete">Delete</string>
<string name="cpp_save">Done</string>
<string name="cpp_cancel">Cancel</string>
<string name="cpp_description">Description</string>
</resources>

View File

@ -9,65 +9,89 @@ import java.util.List;
public class Android {
private static class TranslationLink {
public final String inName;
public final String outName;
private static final List<TranslationLink> settingsLinks = new ArrayList<>();
private static final List<TranslationLink> calendarLinks = new ArrayList<>();
private TranslationLink(String inName, String outName) {
this.inName = inName;
this.outName = outName;
}
static {
settingsLinks.add(new TranslationLink("haptic_feedback_enable_title", "cpp_prefs_vibrate_on_keypress"));
settingsLinks.add(new TranslationLink("accelerometer_title", "cpp_prefs_auto_rotate_screen"));
settingsLinks.add(new TranslationLink("phone_language", "cpp_language"));
settingsLinks.add(new TranslationLink("night_mode_title", "cpp_theme"));
settingsLinks.add(new TranslationLink("night_mode_no", "cpp_theme_light"));
settingsLinks.add(new TranslationLink("night_mode_yes", "cpp_theme_dark"));
settingsLinks.add(new TranslationLink("keep_screen_on", "cpp_prefs_keep_screen_on"));
settingsLinks.add(new TranslationLink("draw_overlay", "cpp_permission_overlay"));
settingsLinks.add(new TranslationLink("yes", "cpp_yes"));
settingsLinks.add(new TranslationLink("no", "cpp_no"));
settingsLinks.add(new TranslationLink("create", "cpp_create"));
settingsLinks.add(new TranslationLink("dlg_close", "cpp_close"));
settingsLinks.add(new TranslationLink("dlg_switch", "cpp_switch"));
calendarLinks.add(new TranslationLink("edit_label", "cpp_edit"));
calendarLinks.add(new TranslationLink("delete_label", "cpp_delete"));
calendarLinks.add(new TranslationLink("save_label", "cpp_save"));
calendarLinks.add(new TranslationLink("discard_label", "cpp_cancel"));
calendarLinks.add(new TranslationLink("hint_description", "cpp_description"));
}
public static void main(String... args) throws Exception {
final Options options = new Options();
options.addOption(Option.builder("as").longOpt("aosp-settings").hasArg().desc("Local location of aosp/platform/packages/apps/settings").required().build());
options.addOption(Option.builder("ac").longOpt("aosp-calendar").hasArg().desc("Local location of aosp/platform/packages/apps/calendar").required().build());
final CommandLineParser parser = new DefaultParser();
final CommandLine commandLine = parser.parse(options, args);
final File aospSettings = new File(commandLine.getOptionValue("as"));
if (!aospSettings.exists() || !aospSettings.isDirectory()) {
throw new IllegalArgumentException(aospSettings + " doesn't exist or not a directory");
}
final File inDir =
new File(aospSettings, "res");
final File aospSettings = makeInputDirectory(commandLine.getOptionValue("as"));
final File aospCalendar = makeInputDirectory(commandLine.getOptionValue("ac"));
final File outDir = new File("build/translations/res");
Utils.delete(outDir);
outDir.mkdirs();
final List<TranslationLink> translationLinks = new ArrayList<>();
translationLinks.add(new TranslationLink("haptic_feedback_enable_title", "cpp_prefs_vibrate_on_keypress"));
translationLinks.add(new TranslationLink("accelerometer_title", "cpp_prefs_auto_rotate_screen"));
translationLinks.add(new TranslationLink("phone_language", "cpp_language"));
translationLinks.add(new TranslationLink("night_mode_title", "cpp_theme"));
translationLinks.add(new TranslationLink("night_mode_no", "cpp_theme_light"));
translationLinks.add(new TranslationLink("night_mode_yes", "cpp_theme_dark"));
translationLinks.add(new TranslationLink("keep_screen_on", "cpp_prefs_keep_screen_on"));
translationLinks.add(new TranslationLink("draw_overlay", "cpp_permission_overlay"));
translationLinks.add(new TranslationLink("yes", "cpp_yes"));
translationLinks.add(new TranslationLink("no", "cpp_no"));
translationLinks.add(new TranslationLink("create", "cpp_create"));
translationLinks.add(new TranslationLink("dlg_close", "cpp_close"));
translationLinks.add(new TranslationLink("dlg_switch", "cpp_switch"));
List<String> languageLocales = new ArrayList<>(Utils.languageLocales);
languageLocales.add("");
for (String languageLocale : languageLocales) {
final File inLanguageDir = new File(inDir, Utils.valuesFolderName(languageLocale));
final File inFile = new File(inLanguageDir, "strings.xml");
final Resources resources = Utils.persister.read(Resources.class, inFile);
Resources translations = new Resources();
for (TranslationLink translationLink : translationLinks) {
String translation = translate(resources, translationLink);
if(!TextUtils.isBlank(translation)) {
translations.strings.add(new ResourceString(translationLink.outName, translation));
}
}
translate(readResources(aospSettings, languageLocale), translations, settingsLinks);
translate(readResources(aospCalendar, languageLocale), translations, calendarLinks);
Utils.saveTranslations(translations, languageLocale, outDir, "text_imported.xml");
}
}
private static Resources readResources(File from, String languageLocale) throws Exception {
File inFile = makeStringsFile(from, languageLocale);
if(!inFile.exists()) {
final int i = languageLocale.indexOf("-r");
if(i >= 0) {
inFile = makeStringsFile(from, languageLocale.substring(0, i));
}
}
return Utils.persister.read(Resources.class, inFile);
}
private static File makeStringsFile(File from, String languageLocale) {
return new File(new File(from, Utils.valuesFolderName(languageLocale)), "strings.xml");
}
private static File makeInputDirectory(String dirName) {
final File dir = new File(dirName);
if (!dir.exists() || !dir.isDirectory()) {
throw new IllegalArgumentException(dir + " doesn't exist or not a directory");
}
return new File(dir, "res");
}
private static void translate(Resources from, Resources to, List<TranslationLink> links) {
for (TranslationLink translationLink : links) {
String translation = translate(from, translationLink);
if (!TextUtils.isBlank(translation)) {
to.strings.add(new ResourceString(translationLink.outName, translation));
}
}
}
private static String translate(Resources resources, TranslationLink translationLink) {
for (ResourceString string : resources.strings) {
if (string.name.equals(translationLink.inName)) {
@ -83,4 +107,14 @@ public class Android {
}
return null;
}
private static class TranslationLink {
public final String inName;
public final String outName;
private TranslationLink(String inName, String outName) {
this.inName = inName;
this.outName = outName;
}
}
}