From 97f8809f5922bc8a3cbc1bcc35f0457e0c7c87f6 Mon Sep 17 00:00:00 2001 From: Silvan Perego Date: Tue, 28 Jun 2022 14:35:44 +0200 Subject: [PATCH 1/2] Add auto-translation feature for Google-Translation Lookups. --- eclipse-rbe-plugin/META-INF/MANIFEST.MF | 5 +- .../OSGI-INF/l10n/bundle.properties | 4 + .../OSGI-INF/l10n/bundle_de.properties | 4 + .../OSGI-INF/l10n/bundle_es.properties | 4 + .../OSGI-INF/l10n/bundle_fr.properties | 4 + .../OSGI-INF/l10n/bundle_it.properties | 4 + .../OSGI-INF/l10n/bundle_ja.properties | 4 + .../OSGI-INF/l10n/bundle_nn_NO.properties | 4 + .../OSGI-INF/l10n/bundle_no.properties | 4 + .../OSGI-INF/l10n/bundle_pt.properties | 4 + .../OSGI-INF/l10n/bundle_zh.properties | 4 + .../OSGI-INF/l10n/bundle_zh_HK.properties | 4 + .../OSGI-INF/l10n/bundle_zh_TW.properties | 4 + eclipse-rbe-plugin/plugin.xml | 6 + .../rbe/model/workbench/RBEPreferences.java | 101 +++++++++------- .../rbe/preferences/PreferenceConstants.java | 16 +++ .../preferences/PreferenceInitializer.java | 26 ++++ .../editor/i18n/GoogleTranslationCaller.java | 113 ++++++++++++++++++ .../eclipse/rbe/ui/editor/i18n/I18nPage.java | 38 +++--- .../rbe/ui/editor/i18n/I18nPageEditor.java | 3 +- .../preferences/RBEPreferenceInitializer.java | 6 +- .../ui/preferences/RBETranslatePrefPage.java | 90 ++++++++++++++ 22 files changed, 391 insertions(+), 61 deletions(-) create mode 100644 eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/preferences/PreferenceConstants.java create mode 100644 eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/preferences/PreferenceInitializer.java create mode 100644 eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/GoogleTranslationCaller.java create mode 100644 eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/preferences/RBETranslatePrefPage.java diff --git a/eclipse-rbe-plugin/META-INF/MANIFEST.MF b/eclipse-rbe-plugin/META-INF/MANIFEST.MF index 2c1bdc1..23bd5ab 100644 --- a/eclipse-rbe-plugin/META-INF/MANIFEST.MF +++ b/eclipse-rbe-plugin/META-INF/MANIFEST.MF @@ -15,6 +15,9 @@ Require-Bundle: org.eclipse.ui, org.eclipse.ui.editors, org.eclipse.ui.ide, org.eclipse.ui.views, - org.eclipse.jdt.ui;resolution:=optional + org.eclipse.jdt.ui;resolution:=optional, + com.fasterxml.jackson.core.jackson-databind, + com.fasterxml.jackson.core.jackson-annotations, + com.fasterxml.jackson.core.jackson-core diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle.properties index ead9ff0..5367130 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle.properties @@ -101,6 +101,10 @@ prefs.showGeneratedBy = Show "Generated By..." header comment (s prefs.spacesAroundEquals = At least one space each side of equal signs. prefs.supportFragments = Support loading of resources from fragment prefs.supportNL = Support Eclipse "nl" structure for plugin internationalization. +prefs.translate.apiKey = Google API-Key +prefs.translate.defaultLang = Default Language +prefs.translate.google = Google Translate +prefs.translate.intro = Register a google cloud API key in order to enable translations via "Google Translate" service. prefs.wrapAlignEquals = Align wrapped lines with equal signs. prefs.wrapIndent = How many spaces to use for indentation: prefs.wrapIndent.error = The 'How many spaces to use...' field must be numeric. diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_de.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_de.properties index ab1b11b..5c79e7b 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_de.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_de.properties @@ -100,6 +100,10 @@ prefs.showGeneratedBy = Zeige "Erstellt von..." Kopfzeilenkommen prefs.spacesAroundEquals = Mindestens ein Leerzeichen links und rechts eines Gleichheitszeichens lassen. prefs.supportFragments = Laden von Ressourcen aus Fragment-Projekten unterst\u00FCtzen prefs.supportNL = Unterst\u00FCtzen der Eclipse "nl"-Struktur f\u00FCr PlugIn-Internationalisierung. +prefs.translate.apiKey = Google API-Key +prefs.translate.defaultLang = Sprache der Vorgabe +prefs.translate.google = Google Translate +prefs.translate.intro = Registrieren Sie einen Google-Cloud API-Key um automatische \u00DCbersetzungen via "Google Translate" zu erm\u00F6glichen. prefs.wrapAlignEquals = Ausrichten umgebrochener Zeilen mit gleichen Zeichen. prefs.wrapIndent = Anzahl der Leerzeichen f\u00FCr die Einr\u00FCckung: prefs.wrapIndent.error = Das "Anzahl der Leerzeichen f\u00FCr die Einr\u00FCckung"-Feld mu\u00DF numerisch sein. diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_es.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_es.properties index 0d6f3df..48a2430 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_es.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_es.properties @@ -101,6 +101,10 @@ prefs.showGeneratedBy = Incluir comentario de "Generated By..." prefs.spacesAroundEquals = Incluir por lo menos un espacio a cada lado del signo igual. prefs.supportFragments = Soportar la carga de recursos desde fragmentos prefs.supportNL = Soportar estructura de Eclipse "nl" para internacionalizaci\u00F3n de plugins. +prefs.translate.apiKey = Clave de la API de Google +prefs.translate.defaultLang = idioma predeterminado +prefs.translate.google = Google Translate +prefs.translate.intro = Registre una clave API de Google Cloud para habilitar las traducciones autom\u00E1ticas a trav\u00E9s de "Google Translate". prefs.wrapAlignEquals = Alinear renglones con el signo igual. prefs.wrapIndent = N\u00FAmero de espacios utilizados para la indentaci\u00F3n: prefs.wrapIndent.error = El n\u00FAmero de espacios utilizados debe ser num\u00E9rico. diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_fr.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_fr.properties index 1f63f59..8b98af9 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_fr.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_fr.properties @@ -100,6 +100,10 @@ prefs.showGeneratedBy = Afficher le commentaire d'en-t\u00EAte " prefs.spacesAroundEquals = Au moins un espace chaque c\u00F4t\u00E9 des symboles d'\u00E9gal. prefs.supportFragments = Supporte le chargement des ressources de fragment prefs.supportNL = Supporter la structure "nl" d'Eclipse pour l'internationalization des rustines. +prefs.translate.apiKey = Cl\u00E9 API Google +prefs.translate.defaultLang = langage par d\u00E9faut +prefs.translate.google = Google Translate +prefs.translate.intro = Enregistrez une cl\u00E9 API Google Cloud pour activer les traductions automatiques via "Google Translate". prefs.wrapAlignEquals = Aligner les lignes coup\u00E9es avec les symboles d'\u00E9gal. prefs.wrapIndent = Combien d'espaces \u00E0 utiliser pour l'indentation : prefs.wrapIndent.error = Le champ 'Combien d'espace \u00E0 utiliser...' doit \u00EAtre num\u00E9rique. diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_it.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_it.properties index 1873f26..e1bf693 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_it.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_it.properties @@ -100,6 +100,10 @@ prefs.showGeneratedBy = Inserisci commento "Generato da..." in t prefs.spacesAroundEquals = Inserisci spazio prima e dopo segni di uguale. prefs.supportFragments = Supporte le chargement des ressources de fragment prefs.supportNL = Supporta l'internazionalizzazione dei plugin di Eclipse (directories "nl"). +prefs.translate.apiKey = Chiave API di Google +prefs.translate.defaultLang = lingua di default +prefs.translate.google = Google Traduttore +prefs.translate.intro = Registra una chiave API Google Cloud per abilitare le traduzioni automatiche tramite "Google Translate". prefs.wrapAlignEquals = Allinea le linee spezzate con i segni di uguale. prefs.wrapIndent = Numero di spazi per l'indentazione prefs.wrapIndent.error = Il numero di spazi per l'indentazione deve essere un valore numerico. diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_ja.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_ja.properties index ca26fc0..e4d9bcc 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_ja.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_ja.properties @@ -100,6 +100,10 @@ prefs.showGeneratedBy = "Generated By..."\u30D8\u30C3\u30C0\u30F prefs.spacesAroundEquals = \u30A4\u30B3\u30FC\u30EB\u8A18\u53F7\u306E\u4E21\u8107\u306B\u30B9\u30DA\u30FC\u30B9\u3092\u633F\u5165\u3059\u308B prefs.supportFragments = Supporte le chargement des ressources de fragment prefs.supportNL = \u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u56FD\u969B\u5316(i18n)\u6642\u306B\u4F7F\u3046Eclipse\u306E"nl"\u69CB\u9020\u3092\u30B5\u30DD\u30FC\u30C8\u3059\u308B +prefs.translate.apiKey = GoogleAPI\u30AD\u30FC +prefs.translate.defaultLang = \u65E2\u5B9A\u306E\u8A00\u8A9E +prefs.translate.google = \u30B0\u30FC\u30B0\u30EB\u7FFB\u8A33 +prefs.translate.intro = Google Cloud API\u30AD\u30FC\u3092\u767B\u9332\u3057\u3066\u3001\u300CGoogle\u7FFB\u8A33\u300D\u306B\u3088\u308B\u81EA\u52D5\u7FFB\u8A33\u3092\u6709\u52B9\u306B\u3057\u307E\u3059\u3002 prefs.wrapAlignEquals = \u30A4\u30B3\u30FC\u30EB\u8A18\u53F7\u306E\u4F4D\u7F6E\u306B\u884C\u3092\u6574\u5217\u3059\u308B prefs.wrapIndent = \u30A4\u30F3\u30C7\u30F3\u30C8\u30B5\u30A4\u30BA(\u30B9\u30DA\u30FC\u30B9\u6570): prefs.wrapIndent.error = '\u30A4\u30F3\u30C7\u30F3\u30C8\u30B5\u30A4\u30BA(\u30B9\u30DA\u30FC\u30B9\u6570):'\u9805\u76EE\u306F\u6570\u5024\u3092\u5165\u529B\u3057\u3066\u4E0B\u3055\u3044 diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_nn_NO.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_nn_NO.properties index 2d9ab14..b3f2a80 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_nn_NO.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_nn_NO.properties @@ -100,6 +100,10 @@ prefs.showGeneratedBy = Vis "Laget av..." toppkommentar (vis din prefs.spacesAroundEquals = Minst eitt mellomrom p\u00E5 kvar side av likhetstekn. prefs.supportFragments = Supporte le chargement des ressources de fragment prefs.supportNL = St\u00F8tt Eclipse "nl" struktur for internasjonalisering av plugins. +prefs.translate.apiKey = Google API-n\u00F8kkel +prefs.translate.defaultLang = standardspr\u00E5k +prefs.translate.google = Google Oversetter +prefs.translate.intro = Registrer en Google Cloud API-n\u00F8kkel for \u00E5 aktivere automatiske oversettelser via "Google Translate". prefs.wrapAlignEquals = Juster brukne linjer saman med likhetsteknene. prefs.wrapIndent = Kor mange mellomrom for indentering: prefs.wrapIndent.error = 'Kor mange mellomrom for...'-feltet m\u00E5 v\u00E6re numerisk. diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_no.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_no.properties index 4aab153..a393ab2 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_no.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_no.properties @@ -100,6 +100,10 @@ prefs.showGeneratedBy = Vis "Laget av..." toppkommentar (vis din prefs.spacesAroundEquals = Minst ett mellomrom p\u00E5 hver side av likhetstegn. prefs.supportFragments = Supporte le chargement des ressources de fragment prefs.supportNL = St\u00F8tt Eclipse "nl" struktur for internasjonalisering av plugins. +prefs.translate.apiKey = Google API-n\u00F8kkel +prefs.translate.defaultLang = standardspr\u00E5k +prefs.translate.google = Google Oversetter +prefs.translate.intro = Registrer en Google Cloud API-n\u00F8kkel for \u00E5 aktivere automatiske oversettelser via "Google Translate". prefs.wrapAlignEquals = Juster brukne linjer sammen med likhetstegnene. prefs.wrapIndent = Antall mellomrom for indentering: prefs.wrapIndent.error = 'Antall mellomrom for...'-feltet m\u00E5 v\u00E6re numerisk. diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_pt.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_pt.properties index 103337c..2aa14d2 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_pt.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_pt.properties @@ -100,6 +100,10 @@ prefs.showGeneratedBy = Inclui "Generated By..." no in\u00EDcio prefs.spacesAroundEquals = Coloca pelo menos um espa\u00E7o em cada lado do s\u00EDmbolo igual. prefs.supportFragments = Supporte le chargement des ressources de fragment prefs.supportNL = Suporte para o estilo "nl" de internacionaliza\u00E7\u00E3o de plugins do Eclipse. +prefs.translate.apiKey = Chave de API do Google +prefs.translate.defaultLang = idioma padr\u00E3o +prefs.translate.google = Google Tradutor +prefs.translate.intro = Registre uma chave de API do Google Cloud para ativar tradu\u00E7\u00F5es autom\u00E1ticas por meio do "Google Translate". prefs.wrapAlignEquals = A quebra de linha ser\u00E1 alinhada com o s\u00EDmbolo igual. prefs.wrapIndent = N\u00FAmero de espa\u00E7os para indenta\u00E7\u00E3o: prefs.wrapIndent.error = O campo 'N\u00FAmero de espa\u00E7os para indenta\u00E7\u00E3o' deve ser num\u00E9rico. diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh.properties index 7f55fae..e5249ed 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh.properties @@ -101,6 +101,10 @@ prefs.showGeneratedBy = \u6587\u4EF6\u5934\u6DFB\u52A0\u6CE8\u91 prefs.spacesAroundEquals = \u7B49\u53F7\u4E24\u8FB9\u81F3\u5C11\u6709\u4E00\u4E2A\u7A7A\u683C prefs.supportFragments = Supporte le chargement des ressources de fragment prefs.supportNL = \u652F\u6301Eclipse\u7528\u4E8E\u63D2\u4EF6\u56FD\u9645\u5316\u7684\u201Cnl\u201D\u7ED3\u6784 +prefs.translate.apiKey = \u8C37\u6B4C API \u5BC6\u94A5 +prefs.translate.defaultLang = \u9ED8\u8BA4\u8BED\u8A00 +prefs.translate.google = \u8C37\u6B4C\u7FFB\u8BD1 +prefs.translate.intro = \u6CE8\u518C Google Cloud API \u5BC6\u94A5\u4EE5\u901A\u8FC7\u201CGoogle Translate\u201D\u542F\u7528\u81EA\u52A8\u7FFB\u8BD1\u3002 prefs.wrapAlignEquals = \u6298\u884C\u65F6\u6309\u7B49\u53F7\u5BF9\u9F50 prefs.wrapIndent = \u7F29\u8FDB\u7684\u5B57\u7B26\u6570\uFF1A prefs.wrapIndent.error = \u201C\u7F29\u8FDB\u5B57\u7B26\u6570\u201D\u5FC5\u987B\u662F\u6570\u5B57\u3002 diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_HK.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_HK.properties index 0adb9e3..841cff9 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_HK.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_HK.properties @@ -101,6 +101,10 @@ prefs.showGeneratedBy = \u6587\u4EF6\u982D\u6DFB\u52A0\u6CE8\u91 prefs.spacesAroundEquals = \u7B49\u865F\u5169\u908A\u81F3\u5C11\u6709\u4E00\u500B\u7A7A\u683C prefs.supportFragments = Supporte le chargement des ressources de fragment prefs.supportNL = \u652F\u6301Eclipse\u7528\u65BC\u63D2\u4EF6\u570B\u969B\u5316\u7684\u201Cnl\u201D\u7D50\u69CB +prefs.translate.apiKey = \u8C37\u6B4C API \u5BC6\u94A5 +prefs.translate.defaultLang = \u9ED8\u8BA4\u8BED\u8A00 +prefs.translate.google = \u8C37\u6B4C\u7FFB\u8BD1 +prefs.translate.intro = \u6CE8\u518C Google Cloud API \u5BC6\u94A5\u4EE5\u901A\u8FC7\u201CGoogle Translate\u201D\u542F\u7528\u81EA\u52A8\u7FFB\u8BD1\u3002 prefs.wrapAlignEquals = \u6298\u884C\u6642\u6309\u7B49\u865F\u5C0D\u9F4A prefs.wrapIndent = \u7E2E\u9032\u7684\u5B57\u5143\u6578\uFF1A prefs.wrapIndent.error = \u201C\u7E2E\u9032\u5B57\u5143\u6578\u201D\u5FC5\u9808\u662F\u6578\u5B57\u3002 diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_TW.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_TW.properties index c8813cf..53374ee 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_TW.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_TW.properties @@ -101,6 +101,10 @@ prefs.showGeneratedBy = \u6587\u4EF6\u982D\u6DFB\u52A0\u6CE8\u91 prefs.spacesAroundEquals = \u7B49\u865F\u5169\u908A\u81F3\u5C11\u6709\u4E00\u500B\u7A7A\u683C prefs.supportFragments = Supporte le chargement des ressources de fragment prefs.supportNL = \u652F\u6301Eclipse\u7528\u65BC\u63D2\u4EF6\u570B\u969B\u5316\u7684\u201Cnl\u201D\u7D50\u69CB +prefs.translate.apiKey = \u8C37\u6B4C API \u5BC6\u94A5 +prefs.translate.defaultLang = \u9ED8\u8BA4\u8BED\u8A00 +prefs.translate.google = \u8C37\u6B4C\u7FFB\u8BD1 +prefs.translate.intro = \u6CE8\u518C Google Cloud API \u5BC6\u94A5\u4EE5\u901A\u8FC7\u201CGoogle Translate\u201D\u542F\u7528\u81EA\u52A8\u7FFB\u8BD1\u3002 prefs.wrapAlignEquals = \u6298\u884C\u6642\u6309\u7B49\u865F\u5C0D\u9F4A prefs.wrapIndent = \u7E2E\u9032\u7684\u5B57\u5143\u6578\uFF1A prefs.wrapIndent.error = \u201C\u7E2E\u9032\u5B57\u5143\u6578\u201D\u5FC5\u9808\u662F\u6578\u5B57\u3002 diff --git a/eclipse-rbe-plugin/plugin.xml b/eclipse-rbe-plugin/plugin.xml index e2e1121..264e292 100644 --- a/eclipse-rbe-plugin/plugin.xml +++ b/eclipse-rbe-plugin/plugin.xml @@ -48,6 +48,12 @@ category="com.essiembre.eclipse.rbe.ui.preferences.RBEGeneralPrefPage" name="%prefs.performance" id="com.essiembre.eclipse.rbe.ui.preferences.RBEReportingPrefPage"/> + + true there if should be spaces around equals signs */ @@ -318,12 +324,12 @@ public static boolean getConvertUnicodeToEncoded() { } /** * Gets whether escaped unicode "alpha" characters should be uppercase - * when generating file. + * when generating file. * @return true if uppercase */ public static boolean getConvertUnicodeToEncodedUpper() { return PREFS.getBoolean(CONVERT_UNICODE_TO_ENCODED_UPPER); - } + } /** * Gets the new line type to use when overwriting system (or Eclipse) * default new line type when generating file. Use constants to this @@ -357,7 +363,7 @@ public static boolean getForceNewLineType() { return PREFS.getBoolean(FORCE_NEW_LINE_TYPE); } - + //--- Reporting/Performance ------------------------------------------------ /** @@ -399,11 +405,26 @@ public static boolean getReportSimilarValuesLevensthein() { } /** * Gets the minimum precision level to use for determining when to report - * similarities. + * similarities. * @return precision */ public static double getReportSimilarValuesPrecision() { return PREFS.getDouble(REPORT_SIM_VALUES_PRECISION); } + /** + * Returns the translation API key that is used to log in to google cloud translation service. + * @return the api key. + */ + public static String getTranslationApiKey() { + return PREFS.getString(TRANSLATION_API_KEY); + } + + /** + * Returns the language that should be used to fill the default language field. + * @return the language. + */ + public static String getTranslationDefaultLanguage() { + return PREFS.getString(TRANSLATION_DEFAULT_LANG); + } } diff --git a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/preferences/PreferenceConstants.java b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/preferences/PreferenceConstants.java new file mode 100644 index 0000000..535c49c --- /dev/null +++ b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/preferences/PreferenceConstants.java @@ -0,0 +1,16 @@ +package com.essiembre.eclipse.rbe.preferences; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + + public static final String P_PATH = "pathPreference"; + + public static final String P_BOOLEAN = "booleanPreference"; + + public static final String P_CHOICE = "choicePreference"; + + public static final String P_STRING = "stringPreference"; + +} diff --git a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/preferences/PreferenceInitializer.java b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/preferences/PreferenceInitializer.java new file mode 100644 index 0000000..0f77d5a --- /dev/null +++ b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/preferences/PreferenceInitializer.java @@ -0,0 +1,26 @@ +package com.essiembre.eclipse.rbe.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +import com.essiembre.eclipse.rbe.RBEPlugin; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = RBEPlugin.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.P_BOOLEAN, true); + store.setDefault(PreferenceConstants.P_CHOICE, "choice2"); + store.setDefault(PreferenceConstants.P_STRING, + "Default value"); + } + +} diff --git a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/GoogleTranslationCaller.java b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/GoogleTranslationCaller.java new file mode 100644 index 0000000..9200332 --- /dev/null +++ b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/GoogleTranslationCaller.java @@ -0,0 +1,113 @@ +package com.essiembre.eclipse.rbe.ui.editor.i18n; + +import java.io.IOException; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.StringJoiner; +import java.util.regex.Pattern; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; + +import com.essiembre.eclipse.rbe.model.workbench.RBEPreferences; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +final class GoogleTranslationCaller implements SelectionListener { + + private static final String UTF_8 = "UTF-8"; + private static final Pattern EMPTY_STRING = Pattern.compile("\\s*"); + + private List entryComposites; + + GoogleTranslationCaller(List entryComposites) { + this.entryComposites = entryComposites; + } + + @Override + public void widgetSelected(SelectionEvent arg0) { + BundleEntryComposite original = null; + for (BundleEntryComposite compos : entryComposites) { + String text = compos.getTextViewer().getDocument().get(); + if (!empty(text)) { + original = compos; + break; + } + } + if (original != null) { + String oriText = original.getTextViewer().getDocument().get(); + for (BundleEntryComposite compos : entryComposites) { + if (compos != original) { + IDocument docu = compos.getTextViewer().getDocument(); + if (empty(docu.get())) + try { + docu.set(translate(oriText, langOf(original), langOf(compos))); + compos.updateBundleOnChanges(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + } + } + + private String langOf(BundleEntryComposite original) { + return original.getLocale() != null ? original.getLocale().getLanguage() : null; + } + + private String translate(String oriText, String sourceLang, String targetLang) throws IOException { + URL url = new URL("https://translation.googleapis.com/language/translate/v2"); + URLConnection con = url.openConnection(); + HttpURLConnection http = (HttpURLConnection)con; + http.setRequestMethod("POST"); + http.setDoOutput(true); + Map arguments = new HashMap(); + arguments.put("q", oriText); + if (!empty(sourceLang)) + arguments.put("source", sourceLang); + arguments.put("target", empty(targetLang) ? RBEPreferences.getTranslationDefaultLanguage() : targetLang); + arguments.put("format", "text"); + arguments.put("key", RBEPreferences.getTranslationApiKey()); + StringJoiner sj = new StringJoiner("&"); + for(Map.Entry entry : arguments.entrySet()) + sj.add(URLEncoder.encode(entry.getKey(), UTF_8) + "=" + + URLEncoder.encode(entry.getValue(), UTF_8)); + byte[] out = sj.toString().getBytes(StandardCharsets.UTF_8); + int length = out.length; + http.setFixedLengthStreamingMode(length); + http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); + http.connect(); + try (OutputStream os = http.getOutputStream()) { + os.write(out); + } + ObjectMapper mapper = new ObjectMapper(); + JsonNode root = mapper.readTree(http.getInputStream()); + JsonNode transText = root.path("data").path("translations"); + sj = new StringJoiner(" "); + if (transText.isMissingNode()) + throw new IOException("No translation found in server response"); + else + for (JsonNode transNode : transText) { + sj.add(transNode.path("translatedText").textValue()); + }; + return sj.toString(); + } + + static boolean empty(String text) { + return text == null || EMPTY_STRING.matcher(text).matches(); + } + + @Override + public void widgetDefaultSelected(SelectionEvent arg0) { + // Nothing to do here. + } +} \ No newline at end of file diff --git a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPage.java b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPage.java index ed0b020..9561165 100644 --- a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPage.java +++ b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPage.java @@ -37,6 +37,7 @@ import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -54,7 +55,7 @@ /** * Internationalization page where one can edit all resource bundle entries at * once for all supported locales. - * + * * @author Pascal Essiembre * @author cuhiodtick */ @@ -62,8 +63,7 @@ public class I18nPage extends ScrolledComposite { private final ResourceManager resourceMediator; private final KeyTreeComposite keysComposite; - private final List entryComposites = - new ArrayList<>(); + private final List entryComposites = new ArrayList<>(); private final LocalBehaviour localBehaviour = new LocalBehaviour(); private final ScrolledComposite editingComposite; @@ -73,10 +73,11 @@ public class I18nPage extends ScrolledComposite { private AutoMouseWheelAdapter _autoMouseWheelAdapter; // boolean _autoAdjustNeeded; private Composite _rightComposite; + private Button pushbutton; /** * Constructor. - * + * * @param parent * parent component. * @param style @@ -148,7 +149,7 @@ public I18nPage(Composite parent, int style, /** * Gets selected key. - * + * * @return selected key */ private String getSelectedKey() { @@ -157,7 +158,7 @@ private String getSelectedKey() { /** * Creates right side of main sash form. - * + * * @param sashForm * parent sash form */ @@ -171,7 +172,7 @@ private void createSashRightSide() { /** * Creates the editing parts which are display within the supplied parental * ScrolledComposite instance. - * + * * @param parent * A container to collect the bundle entry editors. */ @@ -189,8 +190,13 @@ private void createEditingPart(ScrolledComposite parent) { * RBEPreferences.getMinHeight())); // } _rightComposite.setLayout(new GridLayout(1, false)); + if (!GoogleTranslationCaller.empty(RBEPreferences.getTranslationApiKey())) { + pushbutton = new Button(_rightComposite, SWT.PUSH); + pushbutton.setText("Translate!"); + pushbutton.addSelectionListener(new GoogleTranslationCaller(entryComposites)); + } entryComposites.clear(); - for (Iterator iter = resourceMediator.getLocales().iterator(); + for (Iterator iter = resourceMediator.getLocales().iterator(); iter.hasNext();) { Locale locale = (Locale) iter.next(); BundleEntryComposite entryComposite = new BundleEntryComposite( @@ -204,7 +210,7 @@ private void createEditingPart(ScrolledComposite parent) { * This method focusses the {@link BundleEntryComposite} corresponding to * the given {@link Locale}. If no such composite exists or the locale is * null, nothing happens. - * + * * @param locale * The locale whose {@link BundleEntryComposite} is to be * focussed. @@ -251,7 +257,7 @@ public void focusPreviousBundleEntryComposite() { /** * Focusses the given {@link BundleEntryComposite} and scrolls the * surrounding {@link ScrolledComposite} in order to make it visible. - * + * * @param comp * The {@link BundleEntryComposite} to be focussed. */ @@ -317,7 +323,7 @@ public void refreshEditorOnChanges() { */ public void refreshTextBoxes() { String key = getSelectedKey(); - for (Iterator iter = entryComposites.iterator(); + for (Iterator iter = entryComposites.iterator(); iter.hasNext();) { BundleEntryComposite entryComposite = iter.next(); entryComposite.refresh(key); @@ -341,7 +347,7 @@ public void dispose() { if (keysComposite != null) { keysComposite.dispose(); } - for (Iterator iter = entryComposites.iterator(); + for (Iterator iter = entryComposites.iterator(); iter.hasNext();) { iter.next().dispose(); } @@ -431,7 +437,7 @@ private class FindReplaceTarget implements IFindReplaceTarget, @Override public int findAndSelect(int widgetOffset, String findString, - boolean searchForward, + boolean searchForward, boolean caseSensitive, boolean wholeWord) { // replaced by findAndSelect(.,.) return -1; @@ -458,12 +464,12 @@ public int findAndSelect(int offset, String findString, BundleGroup bundleGroup = resourceMediator.getBundleGroup(); ArrayList keys = new ArrayList( bundleGroup.getKeys()); - String activeKey = lastActiveEntry != null ? + String activeKey = lastActiveEntry != null ? lastActiveEntry.activeKey : keys.get(0); int activeKeyIndex = Math.max(keys.indexOf(activeKey), 0); List locales = resourceMediator.getLocales(); - Locale activeLocale = lastActiveEntry != null + Locale activeLocale = lastActiveEntry != null ? lastActiveEntry.locale : locales.get(0); int activeLocaleIndex = locales.indexOf(activeLocale) @@ -508,7 +514,7 @@ private IRegion find(String text, String findString, int offset, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch) { Document document = new Document(text); - FindReplaceDocumentAdapter documentAdapter = + FindReplaceDocumentAdapter documentAdapter = new FindReplaceDocumentAdapter(document); try { return documentAdapter.find(offset, findString, searchForward, diff --git a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPageEditor.java b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPageEditor.java index 36e380d..de4b956 100644 --- a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPageEditor.java +++ b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPageEditor.java @@ -48,7 +48,6 @@ public I18nPage getI18nPage() { @Override public void createPartControl(Composite parent) { i18nPage = new I18nPage(parent, SWT.NONE, resourceMediator); - findReplaceAction = new FindReplaceAction(RBEPlugin.getDefault() .getResourceBundle(), null, i18nPage.getShell(), i18nPage.getReplaceTarget()) { @@ -92,7 +91,7 @@ public T getAdapter(Class required) { return super.getAdapter(required); } catch (NullPointerException e) { RBEPlugin.getDefault().getLog().log(new Status( - Status.ERROR, RBEPlugin.ID, + Status.ERROR, RBEPlugin.ID, "Got a NPE from AbstractTextEditor#getAdapter(Class) " + "for adapter class: " + required, e)); return null; diff --git a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/preferences/RBEPreferenceInitializer.java b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/preferences/RBEPreferenceInitializer.java index 51ad228..0b9070d 100644 --- a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/preferences/RBEPreferenceInitializer.java +++ b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/preferences/RBEPreferenceInitializer.java @@ -23,7 +23,7 @@ /** * Initializes default preferences. - * + * * @author Pascal Essiembre * @author cuhiodtick */ @@ -81,8 +81,10 @@ public void initializeDefaultPreferences() { prefs.setDefault(RBEPreferences.NO_TREE_IN_EDITOR, false); prefs.setDefault(RBEPreferences.MIN_HEIGHT, 80); -// prefs.setDefault(RBEPreferences.AUTO_ADJUST, true); + // Google translation + prefs.setDefault(RBEPreferences.TRANSLATION_API_KEY, ""); + prefs.setDefault(RBEPreferences.TRANSLATION_DEFAULT_LANG, "en"); } } diff --git a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/preferences/RBETranslatePrefPage.java b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/preferences/RBETranslatePrefPage.java new file mode 100644 index 0000000..515c3df --- /dev/null +++ b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/preferences/RBETranslatePrefPage.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2003-2014 Pascal Essiembre + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.essiembre.eclipse.rbe.ui.preferences; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import com.essiembre.eclipse.rbe.RBEPlugin; +import com.essiembre.eclipse.rbe.model.workbench.RBEPreferences; + +/** + * Plugin preference page for reporting/performance options. + * @author Pascal Essiembre + */ +public class RBETranslatePrefPage extends AbstractRBEPrefPage { + + private Text apiKey; + private Text defaultLang; + + /** + * Constructor. + */ + public RBETranslatePrefPage() { + super(); + } + + @Override + protected Control createContents(Composite parent) { + IPreferenceStore prefs = getPreferenceStore(); + Composite field = null; + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout(1, false)); + + new Label(composite, SWT.NONE).setText( + RBEPlugin.getString("prefs.translate.intro")); + new Label(composite, SWT.NONE).setText(" "); + + // Report missing values? + field = createFieldComposite(composite); + new Label(field, SWT.NONE).setText( + RBEPlugin.getString("prefs.translate.apiKey")); + apiKey = new Text(field, SWT.BORDER); + apiKey.setText(prefs.getString(RBEPreferences.TRANSLATION_API_KEY)); + setWidthInChars(apiKey, 40); + field = createFieldComposite(composite); + new Label(field, SWT.NONE).setText( + RBEPlugin.getString("prefs.translate.defaultLang")); + defaultLang = new Text(field, SWT.BORDER); + defaultLang.setText(prefs.getString(RBEPreferences.TRANSLATION_DEFAULT_LANG)); + defaultLang.setTextLimit(2); + setWidthInChars(defaultLang, 2); + return composite; + } + + @Override + public boolean performOk() { + IPreferenceStore prefs = getPreferenceStore(); + prefs.setValue(RBEPreferences.TRANSLATION_API_KEY, apiKey.getText()); + prefs.setValue(RBEPreferences.TRANSLATION_DEFAULT_LANG, defaultLang.getText()); + return super.performOk(); + } + + + @Override + protected void performDefaults() { + IPreferenceStore prefs = getPreferenceStore(); + apiKey.setText(prefs.getDefaultString(RBEPreferences.TRANSLATION_API_KEY)); + defaultLang.setText(prefs.getString(RBEPreferences.TRANSLATION_DEFAULT_LANG)); + super.performDefaults(); + } + +} From 521e830181aee0682e0f82de7825b6d92fafdde6 Mon Sep 17 00:00:00 2001 From: Silvan Perego Date: Wed, 29 Jun 2022 13:53:34 +0200 Subject: [PATCH 2/2] Improve error handling. --- .../OSGI-INF/l10n/bundle.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_de.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_es.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_fr.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_it.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_ja.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_nn_NO.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_no.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_pt.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_zh.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_zh_HK.properties | 14 ++++--- .../OSGI-INF/l10n/bundle_zh_TW.properties | 14 ++++--- .../editor/i18n/GoogleTranslationCaller.java | 42 ++++++++++++++++--- .../eclipse/rbe/ui/editor/i18n/I18nPage.java | 12 ++++-- 14 files changed, 152 insertions(+), 70 deletions(-) diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle.properties index 5367130..f05ed89 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle.properties @@ -26,6 +26,7 @@ editor.new.tab = New... editor.new.title = New properties file: editor.properties = Properties editor.rbe = ResourceBundle Editor +editor.translate = Translate! editor.wiz.add = Add --> editor.wiz.browse = Browse... editor.wiz.bundleName = &Base Name: @@ -41,11 +42,14 @@ editor.wiz.selectFolder = Select a folder editor.wiz.selected = Selected locales editor.wiz.title = ResourceBundle (Properties Files) -error.init.badencoding = Malformed \\uxxxx encoding found in this string: -error.init.ui = Cannot initialize visual component. -error.newfile.cannotCreate = Cannot create new file. -error.newfile.cannotOpen = Cannot open newly created file. -error.seeLogs = See log file for details. +error.init.badencoding = Malformed \\uxxxx encoding found in this string: +error.init.ui = Cannot initialize visual component. +error.newfile.cannotCreate = Cannot create new file. +error.newfile.cannotOpen = Cannot open newly created file. +error.seeLogs = See log file for details. +error.translate.errForLang = Errors occurred for the following languages: {0} +error.translate.noTextToTranslate = There is nothing to be translated. Provide text for at least one language and leave at least one language empty. +error.translate.notranslation = No translation found in server response key.add = &Add key.collapseAll = Co&llapse All diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_de.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_de.properties index 5c79e7b..9ef38e5 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_de.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_de.properties @@ -26,6 +26,7 @@ editor.new.tab = Neu... editor.new.title = Neue Dateieigenschaften editor.properties = Eigenschaften editor.rbe = ResourceBundle Editor +editor.translate = \u00DCbersetzen! editor.wiz.add = Hinzuf\u00FCgen --> editor.wiz.browse = Durchsuchen... editor.wiz.bundleName = Basisname @@ -41,11 +42,14 @@ editor.wiz.selectFolder = W\u00E4hle einen Ordner editor.wiz.selected = Gew\u00E4hlte Lokalisierung editor.wiz.title = ResourceBundle (Properties Dateien) -error.init.badencoding = Malformed \\uxxxx encoding found in this string: -error.init.ui = Kann die visuelle Komponente nicht initialisieren. -error.newfile.cannotCreate = Kann keine neue Datei erstellen. -error.newfile.cannotOpen = Kann die neu angelegte Datei nicht \u00F6ffnen. -error.seeLogs = Siehe Log-Datei f\u00FCr Details. +error.init.badencoding = Malformed \\uxxxx encoding found in this string: +error.init.ui = Kann die visuelle Komponente nicht initialisieren. +error.newfile.cannotCreate = Kann keine neue Datei erstellen. +error.newfile.cannotOpen = Kann die neu angelegte Datei nicht \u00F6ffnen. +error.seeLogs = Siehe Log-Datei f\u00FCr Details. +error.translate.errForLang = F\u00FCr die folgenden Sprachen sind Fehler aufgetreten: {0} +error.translate.noTextToTranslate = Es gibt nichts zu \u00FCbersetzen. Geben Sie Text f\u00FCr mindestens eine Sprache an und lassen Sie mindestens eine Sprache leer. +error.translate.notranslation = Keine \u00DCbersetzung in Serverantwort gefunden key.add = &Anf\u00FCgen key.collapseAll = Alle &zusammenklappen diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_es.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_es.properties index 48a2430..fd025c0 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_es.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_es.properties @@ -26,6 +26,7 @@ editor.new.tab = Nuevo... editor.new.title = Nuevo archivo properties: editor.properties = Propiedades editor.rbe = ResourceBundle Editor +editor.translate = \u00A1Traducir! editor.wiz.add = Agregar --> editor.wiz.browse = Examinar... editor.wiz.bundleName = Nombre: @@ -41,11 +42,14 @@ editor.wiz.selectFolder = Seleccionar una carpeta editor.wiz.selected = Idiomas seleccionados editor.wiz.title = ResourceBundle (Archivos Properties) -error.init.badencoding = Se ha detectado una codificaci\u00F3n \\\\uxxxx err\u00F3nea en este texto: -error.init.ui = No se pudo inicializar el componente gr\u00E1fico. -error.newfile.cannotCreate = No se pudo crear el archivo nuevo. -error.newfile.cannotOpen = No se pudo abrir el archivo reci\u00E9n creado. -error.seeLogs = Para m\u00E1s detalles vea el registro. +error.init.badencoding = Se ha detectado una codificaci\u00F3n \\\\uxxxx err\u00F3nea en este texto: +error.init.ui = No se pudo inicializar el componente gr\u00E1fico. +error.newfile.cannotCreate = No se pudo crear el archivo nuevo. +error.newfile.cannotOpen = No se pudo abrir el archivo reci\u00E9n creado. +error.seeLogs = Para m\u00E1s detalles vea el registro. +error.translate.errForLang = Ocurrieron errores para los siguientes idiomas: {0} +error.translate.noTextToTranslate = No hay nada que traducir. Proporcione texto para al menos un idioma y deje al menos un idioma vac\u00EDo. +error.translate.notranslation = No se encontr\u00F3 traducci\u00F3n en la respuesta del servidor key.add = &Agregar key.collapseAll = Co&lapsar todo diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_fr.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_fr.properties index 8b98af9..b876ad9 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_fr.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_fr.properties @@ -26,6 +26,7 @@ editor.new.tab = Nouveau... editor.new.title = Nouveau fichier de propri\u00E9t\u00E9s : editor.properties = Propri\u00E9t\u00E9s editor.rbe = \u00C9diteur de ResourceBundle +editor.translate = Traduire! editor.wiz.add = Ajouter --> editor.wiz.browse = Naviguer... editor.wiz.bundleName = Nom de base: @@ -41,11 +42,14 @@ editor.wiz.selectFolder = S\u00E9lectionner un dossier editor.wiz.selected = Locales s\u00E9lection\u00E9es editor.wiz.title = ResourceBundle (Fichiers de propri\u00E9t\u00E9s) -error.init.badencoding = Malformed \\uxxxx encoding found in this string: -error.init.ui = Impossible d'initializer unes composante visuelle. -error.newfile.cannotCreate = Impossible de cr\u00E9er un nouveau fichier. -error.newfile.cannotOpen = Impossible d'ouvrir le nouveau fichier. -error.seeLogs = Voir le fichier journal. +error.init.badencoding = Malformed \\uxxxx encoding found in this string: +error.init.ui = Impossible d'initializer unes composante visuelle. +error.newfile.cannotCreate = Impossible de cr\u00E9er un nouveau fichier. +error.newfile.cannotOpen = Impossible d'ouvrir le nouveau fichier. +error.seeLogs = Voir le fichier journal. +error.translate.errForLang = Des erreurs se sont produites pour les langues suivantes\u00A0: {0} +error.translate.noTextToTranslate = Il n'y a rien \u00E0 traduire. Fournissez du texte pour au moins une langue et laissez au moins une langue vide. +error.translate.notranslation = Aucune traduction trouv\u00E9e dans la r\u00E9ponse du serveur key.add = &Ajouter key.collapseAll = &Fermer tous diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_it.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_it.properties index e1bf693..95b5aad 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_it.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_it.properties @@ -26,6 +26,7 @@ editor.new.tab = Nuovo... editor.new.title = Nuovo file di properties: editor.properties = Properties editor.rbe = Editor di Resource Bundle +editor.translate = Tradurre! editor.wiz.add = Aggiungi --> editor.wiz.browse = Sfoglia... editor.wiz.bundleName = &Prefisso: @@ -41,11 +42,14 @@ editor.wiz.selectFolder = Selezionare una cartella editor.wiz.selected = Locale selezionati editor.wiz.title = ResourceBundle (File di properties) -error.init.badencoding = La seguente stringa contiene una codifica X non corretta: -error.init.ui = Non \u00E8 possibile inizializzare il componente visuale. -error.newfile.cannotCreate = Non si pu\u00F2 creare un nuovo file. -error.newfile.cannotOpen = Non si pu\u00F2 aprire il file appena creato. -error.seeLogs = Vedi il file di log per i dettagli. +error.init.badencoding = La seguente stringa contiene una codifica X non corretta: +error.init.ui = Non \u00E8 possibile inizializzare il componente visuale. +error.newfile.cannotCreate = Non si pu\u00F2 creare un nuovo file. +error.newfile.cannotOpen = Non si pu\u00F2 aprire il file appena creato. +error.seeLogs = Vedi il file di log per i dettagli. +error.translate.errForLang = Si sono verificati errori per le seguenti lingue: {0} +error.translate.noTextToTranslate = Non c'\u00E8 niente da tradurre. Fornisci testo per almeno una lingua e lascia vuota almeno una lingua. +error.translate.notranslation = Nessuna traduzione trovata nella risposta del server key.add = &Aggiungi key.collapseAll = Com&primi tutto diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_ja.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_ja.properties index e4d9bcc..ee21830 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_ja.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_ja.properties @@ -26,6 +26,7 @@ editor.new.tab = \u65B0\u898F... editor.new.title = \u65B0\u898F\u30D7\u30ED\u30D1\u30C6\u30A3\u30D5\u30A1\u30A4\u30EB: editor.properties = \u30D7\u30ED\u30D1\u30C6\u30A3 editor.rbe = \u30EA\u30BD\u30FC\u30B9\u30D0\u30F3\u30C9\u30EB\u30A8\u30C7\u30A3\u30BF +editor.translate = \u7FFB\u8A33\uFF01 editor.wiz.add = \u8FFD\u52A0 --> editor.wiz.browse = \u53C2\u7167... editor.wiz.bundleName = \u30D9\u30FC\u30B9\u540D(&B): @@ -41,11 +42,14 @@ editor.wiz.selectFolder = \u30D5\u30A9\u30EB\u30C0\u3092\u9078\u629E editor.wiz.selected = \u9078\u629E\u6E08\u307F\u30ED\u30B1\u30FC\u30EB editor.wiz.title = \u30EA\u30BD\u30FC\u30B9\u30D0\u30F3\u30C9\u30EB(\u30D7\u30ED\u30D1\u30C6\u30A3\u30D5\u30A1\u30A4\u30EB) -error.init.badencoding = \u4E0D\u6B63\u306A \\uxxxx \u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u304C\u6B21\u306E\u6587\u5B57\u5217\u304B\u3089\u691C\u51FA\u3055\u308C\u307E\u3057\u305F: -error.init.ui = \u30D3\u30B8\u30E5\u30A2\u30EB\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u3092\u521D\u671F\u5316\u51FA\u6765\u307E\u305B\u3093\u3067\u3057\u305F\u3002 -error.newfile.cannotCreate = \u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u51FA\u6765\u307E\u305B\u3093\u3002 -error.newfile.cannotOpen = \u751F\u6210\u3055\u308C\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u958B\u3051\u307E\u305B\u3093\u3002 -error.seeLogs = \u8A73\u7D30\u306F\u30ED\u30B0\u30D5\u30A1\u30A4\u30EB\u3092\u53C2\u7167\u3057\u3066\u4E0B\u3055\u3044\u3002 +error.init.badencoding = \u4E0D\u6B63\u306A \\uxxxx \u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u304C\u6B21\u306E\u6587\u5B57\u5217\u304B\u3089\u691C\u51FA\u3055\u308C\u307E\u3057\u305F: +error.init.ui = \u30D3\u30B8\u30E5\u30A2\u30EB\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u3092\u521D\u671F\u5316\u51FA\u6765\u307E\u305B\u3093\u3067\u3057\u305F\u3002 +error.newfile.cannotCreate = \u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u51FA\u6765\u307E\u305B\u3093\u3002 +error.newfile.cannotOpen = \u751F\u6210\u3055\u308C\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u958B\u3051\u307E\u305B\u3093\u3002 +error.seeLogs = \u8A73\u7D30\u306F\u30ED\u30B0\u30D5\u30A1\u30A4\u30EB\u3092\u53C2\u7167\u3057\u3066\u4E0B\u3055\u3044\u3002 +error.translate.errForLang = \u6B21\u306E\u8A00\u8A9E\u3067\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\uFF1A{0} +error.translate.noTextToTranslate = \u7FFB\u8A33\u3059\u308B\u3082\u306E\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u5C11\u306A\u304F\u3068\u30821\u3064\u306E\u8A00\u8A9E\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u63D0\u4F9B\u3057\u3001\u5C11\u306A\u304F\u3068\u30821\u3064\u306E\u8A00\u8A9E\u3092\u7A7A\u306E\u307E\u307E\u306B\u3057\u307E\u3059\u3002 +error.translate.notranslation = \u30B5\u30FC\u30D0\u30FC\u306E\u5FDC\u7B54\u306B\u7FFB\u8A33\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 key.add = \u8FFD\u52A0(&A) key.collapseAll = \u5168\u3066\u30C4\u30EA\u30FC\u3092\u305F\u305F\u3080(&l) diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_nn_NO.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_nn_NO.properties index b3f2a80..0ec8131 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_nn_NO.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_nn_NO.properties @@ -26,6 +26,7 @@ editor.new.tab = Ny... editor.new.title = Ny properties fil: editor.properties = Eigenskapar editor.rbe = ResourceBundle Editor +editor.translate = Oversette! editor.wiz.add = Legg til --> editor.wiz.browse = Bla igjennom... editor.wiz.bundleName = Basisnamn: @@ -41,11 +42,14 @@ editor.wiz.selectFolder = Velg ei mappe editor.wiz.selected = Valt lokalisering editor.wiz.title = ResourceBundle (Properties filer) -error.init.badencoding = Ugyldig x koding funne i denne strengen: -error.init.ui = Kan ikkje sette opp den visuelle komponenten. -error.newfile.cannotCreate = Kan ikkje opprette ny fil. -error.newfile.cannotOpen = Kan ikkje opne den nyoppretta fila. -error.seeLogs = Se loggfilen for detaljar. +error.init.badencoding = Ugyldig x koding funne i denne strengen: +error.init.ui = Kan ikkje sette opp den visuelle komponenten. +error.newfile.cannotCreate = Kan ikkje opprette ny fil. +error.newfile.cannotOpen = Kan ikkje opne den nyoppretta fila. +error.seeLogs = Se loggfilen for detaljar. +error.translate.errForLang = Det oppsto feil for f\u00F8lgende spr\u00E5k: {0} +error.translate.noTextToTranslate = Det er ingenting som skal oversettes. Oppgi tekst for minst ett spr\u00E5k og la minst ett spr\u00E5k st\u00E5 tomt. +error.translate.notranslation = Ingen oversettelse funnet i serversvar key.add = &Legg til key.collapseAll = &Lukk alle diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_no.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_no.properties index a393ab2..68fd4a9 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_no.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_no.properties @@ -26,6 +26,7 @@ editor.new.tab = Ny... editor.new.title = Ny properties fil: editor.properties = Egenskaper editor.rbe = ResourceBundle Editor +editor.translate = Oversette! editor.wiz.add = Legg til --> editor.wiz.browse = Bla igjennom... editor.wiz.bundleName = Basisnavn: @@ -41,11 +42,14 @@ editor.wiz.selectFolder = Velg en mappe editor.wiz.selected = Valgt lokalisering editor.wiz.title = ResourceBundle (Properties filer) -error.init.badencoding = Ugyldig x koding funnet i denne strengen: -error.init.ui = Kan ikke sette opp den visuelle komponenten. -error.newfile.cannotCreate = Kan ikke opprette ny fil. -error.newfile.cannotOpen = Kan ikke \u00E5pne den nyopprettede filen. -error.seeLogs = Se loggfilen for detaljer. +error.init.badencoding = Ugyldig x koding funnet i denne strengen: +error.init.ui = Kan ikke sette opp den visuelle komponenten. +error.newfile.cannotCreate = Kan ikke opprette ny fil. +error.newfile.cannotOpen = Kan ikke \u00E5pne den nyopprettede filen. +error.seeLogs = Se loggfilen for detaljer. +error.translate.errForLang = Det oppsto feil for f\u00F8lgende spr\u00E5k: {0} +error.translate.noTextToTranslate = Det er ingenting som skal oversettes. Oppgi tekst for minst ett spr\u00E5k og la minst ett spr\u00E5k st\u00E5 tomt. +error.translate.notranslation = Ingen oversettelse funnet i serversvar key.add = &Legg til key.collapseAll = &Lukk alle diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_pt.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_pt.properties index 2aa14d2..774796c 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_pt.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_pt.properties @@ -26,6 +26,7 @@ editor.new.tab = Novo... editor.new.title = Novo arquivo de propriedades: editor.properties = Propriedades editor.rbe = Editor de ResourceBundle +editor.translate = Traduzir! editor.wiz.add = Incluir --> editor.wiz.browse = Procurar... editor.wiz.bundleName = Nome &Base: @@ -41,11 +42,14 @@ editor.wiz.selectFolder = Selecione uma pasta editor.wiz.selected = Localiza\u00E7\u00F5es selecionadas editor.wiz.title = ResourceBundle (Arquivos de Propriedades) -error.init.badencoding = Esta senten\u00E7a est\u00E1 com erro de codifica\u00E7\u00E3o (\\uxxxx): -error.init.ui = N\u00E3o foi poss\u00EDvel inicializar o componente visual. -error.newfile.cannotCreate = N\u00E3o foi poss\u00EDvel criar arquivo. -error.newfile.cannotOpen = N\u00E3o foi poss\u00EDvel abrir o novo arquivo. -error.seeLogs = Veja o arquivo de log para maiores detalhes. +error.init.badencoding = Esta senten\u00E7a est\u00E1 com erro de codifica\u00E7\u00E3o (\\uxxxx): +error.init.ui = N\u00E3o foi poss\u00EDvel inicializar o componente visual. +error.newfile.cannotCreate = N\u00E3o foi poss\u00EDvel criar arquivo. +error.newfile.cannotOpen = N\u00E3o foi poss\u00EDvel abrir o novo arquivo. +error.seeLogs = Veja o arquivo de log para maiores detalhes. +error.translate.errForLang = Ocorreram erros para os seguintes idiomas: {0} +error.translate.noTextToTranslate = N\u00E3o h\u00E1 nada a ser traduzido. Forne\u00E7a texto para pelo menos um idioma e deixe pelo menos um idioma em branco. +error.translate.notranslation = Nenhuma tradu\u00E7\u00E3o encontrada na resposta do servidor key.add = &Incluir key.collapseAll = &Fechar tudo diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh.properties index e5249ed..72f9a45 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh.properties @@ -26,6 +26,7 @@ editor.new.tab = \u65B0\u5EFA... editor.new.title = \u65B0\u8D44\u6E90\u6587\u4EF6\uFF1A editor.properties = \u8D44\u6E90 editor.rbe = \u8D44\u6E90\u6587\u4EF6\u7F16\u8F91\u5668 +editor.translate = \u7FFB\u8BD1\uFF01 editor.wiz.add = \u6DFB\u52A0 --> editor.wiz.browse = \u6D4F\u89C8... editor.wiz.bundleName = \u8D44\u6E90\u540D(&B)\uFF1A @@ -41,11 +42,14 @@ editor.wiz.selectFolder = \u8BF7\u9009\u62E9\u6587\u4EF6\u5939 editor.wiz.selected = \u9009\u62E9\u7684\u672C\u5730\u5316\u5C5E\u6027 editor.wiz.title = \u8D44\u6E90\u96C6(\u5C5E\u6027\u6587\u4EF6) -error.init.badencoding = \u8BE5\u5B57\u7B26\u4E32\u4E2D\u6709\u4E0D\u6B63\u786E\u7684 \\uxxxx \u7F16\u7801\uFF1A -error.init.ui = \u521D\u59CB\u5316\u53EF\u89C6\u7EC4\u4EF6\u5931\u8D25\u3002 -error.newfile.cannotCreate = \u4E0D\u80FD\u521B\u5EFA\u65B0\u6587\u4EF6\u3002 -error.newfile.cannotOpen = \u4E0D\u80FD\u6253\u5F00\u65B0\u521B\u5EFA\u7684\u6587\u4EF6\u3002 -error.seeLogs = \u8BF7\u67E5\u770B\u65E5\u5FD7\u6587\u4EF6\u4E2D\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002 +error.init.badencoding = \u8BE5\u5B57\u7B26\u4E32\u4E2D\u6709\u4E0D\u6B63\u786E\u7684 \\uxxxx \u7F16\u7801\uFF1A +error.init.ui = \u521D\u59CB\u5316\u53EF\u89C6\u7EC4\u4EF6\u5931\u8D25\u3002 +error.newfile.cannotCreate = \u4E0D\u80FD\u521B\u5EFA\u65B0\u6587\u4EF6\u3002 +error.newfile.cannotOpen = \u4E0D\u80FD\u6253\u5F00\u65B0\u521B\u5EFA\u7684\u6587\u4EF6\u3002 +error.seeLogs = \u8BF7\u67E5\u770B\u65E5\u5FD7\u6587\u4EF6\u4E2D\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002 +error.translate.errForLang = \u4EE5\u4E0B\u8BED\u8A00\u51FA\u73B0\u9519\u8BEF\uFF1A{0} +error.translate.noTextToTranslate = \u6CA1\u6709\u4EC0\u4E48\u9700\u8981\u7FFB\u8BD1\u7684\u3002\u63D0\u4F9B\u81F3\u5C11\u4E00\u79CD\u8BED\u8A00\u7684\u6587\u672C\uFF0C\u5E76\u81F3\u5C11\u5C06\u4E00\u79CD\u8BED\u8A00\u7559\u7A7A\u3002 +error.translate.notranslation = \u5728\u670D\u52A1\u5668\u54CD\u5E94\u4E2D\u627E\u4E0D\u5230\u7FFB\u8BD1 key.add = \u6DFB\u52A0(&A) key.collapseAll = \u5168\u90E8\u6536\u8D77(&L) diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_HK.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_HK.properties index 841cff9..8e330c8 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_HK.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_HK.properties @@ -26,6 +26,7 @@ editor.new.tab = \u65B0\u5EFA... editor.new.title = \u65B0\u8CC7\u6E90\u6587\u4EF6\uFF1A editor.properties = \u8CC7\u6E90 editor.rbe = \u8CC7\u6E90\u6587\u4EF6\u7DE8\u8F2F\u5668 +editor.translate = \u7FFB\u8BD1\uFF01 editor.wiz.add = \u6DFB\u52A0 --> editor.wiz.browse = \u700F\u89BD... editor.wiz.bundleName = \u8CC7\u6E90\u540D(&B)\uFF1A @@ -41,11 +42,14 @@ editor.wiz.selectFolder = \u8ACB\u9078\u64C7\u6587\u4EF6\u593E editor.wiz.selected = \u9078\u64C7\u7684\u672C\u5730\u5316\u5C6C\u6027 editor.wiz.title = \u8CC7\u6E90\u96C6(\u5C6C\u6027\u6587\u4EF6) -error.init.badencoding = \u8A72\u5B57\u5143\u4E32\u4E2D\u6709\u4E0D\u6B63\u78BA\u7684 \\uxxxx \u7DE8\u78BC\uFF1A -error.init.ui = \u521D\u59CB\u5316\u53EF\u8996\u7D44\u4EF6\u5931\u6557\u3002 -error.newfile.cannotCreate = \u4E0D\u80FD\u5275\u5EFA\u65B0\u6587\u4EF6\u3002 -error.newfile.cannotOpen = \u4E0D\u80FD\u6253\u958B\u65B0\u5275\u5EFA\u7684\u6587\u4EF6\u3002 -error.seeLogs = \u8ACB\u67E5\u770B\u65E5\u8A8C\u6587\u4EF6\u4E2D\u7684\u8A73\u7D30\u4FE1\u606F\u3002 +error.init.badencoding = \u8A72\u5B57\u5143\u4E32\u4E2D\u6709\u4E0D\u6B63\u78BA\u7684 \\uxxxx \u7DE8\u78BC\uFF1A +error.init.ui = \u521D\u59CB\u5316\u53EF\u8996\u7D44\u4EF6\u5931\u6557\u3002 +error.newfile.cannotCreate = \u4E0D\u80FD\u5275\u5EFA\u65B0\u6587\u4EF6\u3002 +error.newfile.cannotOpen = \u4E0D\u80FD\u6253\u958B\u65B0\u5275\u5EFA\u7684\u6587\u4EF6\u3002 +error.seeLogs = \u8ACB\u67E5\u770B\u65E5\u8A8C\u6587\u4EF6\u4E2D\u7684\u8A73\u7D30\u4FE1\u606F\u3002 +error.translate.errForLang = \u4EE5\u4E0B\u8BED\u8A00\u51FA\u73B0\u9519\u8BEF\uFF1A{0} +error.translate.noTextToTranslate = \u6CA1\u6709\u4EC0\u4E48\u9700\u8981\u7FFB\u8BD1\u7684\u3002\u63D0\u4F9B\u81F3\u5C11\u4E00\u79CD\u8BED\u8A00\u7684\u6587\u672C\uFF0C\u5E76\u81F3\u5C11\u5C06\u4E00\u79CD\u8BED\u8A00\u7559\u7A7A\u3002 +error.translate.notranslation = \u5728\u670D\u52A1\u5668\u54CD\u5E94\u4E2D\u627E\u4E0D\u5230\u7FFB\u8BD1 key.add = \u6DFB\u52A0(&A) key.collapseAll = \u5168\u90E8\u6536\u8D77(&L) diff --git a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_TW.properties b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_TW.properties index 53374ee..0901516 100644 --- a/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_TW.properties +++ b/eclipse-rbe-plugin/OSGI-INF/l10n/bundle_zh_TW.properties @@ -26,6 +26,7 @@ editor.new.tab = \u65B0\u5EFA... editor.new.title = \u65B0\u8CC7\u6E90\u6587\u4EF6\uFF1A editor.properties = \u8CC7\u6E90 editor.rbe = \u8CC7\u6E90\u6587\u4EF6\u7DE8\u8F2F\u5668 +editor.translate = \u7FFB\u8BD1\uFF01 editor.wiz.add = \u6DFB\u52A0 --> editor.wiz.browse = \u700F\u89BD... editor.wiz.bundleName = \u8CC7\u6E90\u540D(&B)\uFF1A @@ -41,11 +42,14 @@ editor.wiz.selectFolder = \u8ACB\u9078\u64C7\u6587\u4EF6\u593E editor.wiz.selected = \u9078\u64C7\u7684\u672C\u5730\u5316\u5C6C\u6027 editor.wiz.title = \u8CC7\u6E90\u96C6(\u5C6C\u6027\u6587\u4EF6) -error.init.badencoding = \u8A72\u5B57\u5143\u4E32\u4E2D\u6709\u4E0D\u6B63\u78BA\u7684 \\uxxxx \u7DE8\u78BC\uFF1A -error.init.ui = \u521D\u59CB\u5316\u53EF\u8996\u7D44\u4EF6\u5931\u6557\u3002 -error.newfile.cannotCreate = \u4E0D\u80FD\u5275\u5EFA\u65B0\u6587\u4EF6\u3002 -error.newfile.cannotOpen = \u4E0D\u80FD\u6253\u958B\u65B0\u5275\u5EFA\u7684\u6587\u4EF6\u3002 -error.seeLogs = \u8ACB\u67E5\u770B\u65E5\u8A8C\u6587\u4EF6\u4E2D\u7684\u8A73\u7D30\u4FE1\u606F\u3002 +error.init.badencoding = \u8A72\u5B57\u5143\u4E32\u4E2D\u6709\u4E0D\u6B63\u78BA\u7684 \\uxxxx \u7DE8\u78BC\uFF1A +error.init.ui = \u521D\u59CB\u5316\u53EF\u8996\u7D44\u4EF6\u5931\u6557\u3002 +error.newfile.cannotCreate = \u4E0D\u80FD\u5275\u5EFA\u65B0\u6587\u4EF6\u3002 +error.newfile.cannotOpen = \u4E0D\u80FD\u6253\u958B\u65B0\u5275\u5EFA\u7684\u6587\u4EF6\u3002 +error.seeLogs = \u8ACB\u67E5\u770B\u65E5\u8A8C\u6587\u4EF6\u4E2D\u7684\u8A73\u7D30\u4FE1\u606F\u3002 +error.translate.errForLang = \u4EE5\u4E0B\u8BED\u8A00\u51FA\u73B0\u9519\u8BEF\uFF1A{0} +error.translate.noTextToTranslate = \u6CA1\u6709\u4EC0\u4E48\u9700\u8981\u7FFB\u8BD1\u7684\u3002\u63D0\u4F9B\u81F3\u5C11\u4E00\u79CD\u8BED\u8A00\u7684\u6587\u672C\uFF0C\u5E76\u81F3\u5C11\u5C06\u4E00\u79CD\u8BED\u8A00\u7559\u7A7A\u3002 +error.translate.notranslation = \u5728\u670D\u52A1\u5668\u54CD\u5E94\u4E2D\u627E\u4E0D\u5230\u7FFB\u8BD1 key.add = \u6DFB\u52A0(&A) key.collapseAll = \u5168\u90E8\u6536\u8D77(&L) diff --git a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/GoogleTranslationCaller.java b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/GoogleTranslationCaller.java index 9200332..07556cb 100644 --- a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/GoogleTranslationCaller.java +++ b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/GoogleTranslationCaller.java @@ -13,10 +13,12 @@ import java.util.StringJoiner; import java.util.regex.Pattern; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.text.IDocument; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; +import com.essiembre.eclipse.rbe.RBEPlugin; import com.essiembre.eclipse.rbe.model.workbench.RBEPreferences; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -34,6 +36,7 @@ final class GoogleTranslationCaller implements SelectionListener { @Override public void widgetSelected(SelectionEvent arg0) { + boolean translationsMade = false; BundleEntryComposite original = null; for (BundleEntryComposite compos : entryComposites) { String text = compos.getTextViewer().getDocument().get(); @@ -44,20 +47,30 @@ public void widgetSelected(SelectionEvent arg0) { } if (original != null) { String oriText = original.getTextViewer().getDocument().get(); + Map translationErrors = new HashMap<>(); for (BundleEntryComposite compos : entryComposites) { if (compos != original) { IDocument docu = compos.getTextViewer().getDocument(); - if (empty(docu.get())) + if (empty(docu.get())) { try { docu.set(translate(oriText, langOf(original), langOf(compos))); compos.updateBundleOnChanges(); } catch (IOException e) { e.printStackTrace(); + translationErrors.put(langOf(compos), e.getMessage()); } + translationsMade = true; + } } } - + if (!translationErrors.isEmpty()) { + MessageDialog.openError(entryComposites.get(0).getShell(), "Error", + RBEPlugin.getString("error.translate.errForLang", translationErrors.toString())); + } } + if (!translationsMade) + MessageDialog.openInformation(entryComposites.get(0).getShell(), "Info", + RBEPlugin.getString("error.translate.noTextToTranslate")); } private String langOf(BundleEntryComposite original) { @@ -90,12 +103,29 @@ private String translate(String oriText, String sourceLang, String targetLang) t os.write(out); } ObjectMapper mapper = new ObjectMapper(); - JsonNode root = mapper.readTree(http.getInputStream()); + JsonNode root = null; + IOException ioException = null; + try { + root = mapper.readTree(http.getInputStream()); + } catch (IOException e) { + try { + root = mapper.readTree(http.getErrorStream()); + ioException = e; + } catch (Exception e2) { + throw e; + } + } JsonNode transText = root.path("data").path("translations"); sj = new StringJoiner(" "); - if (transText.isMissingNode()) - throw new IOException("No translation found in server response"); - else + if (transText.isMissingNode()) { + transText = root.path("error").path("message"); + if (transText.isMissingNode()) + if (ioException != null) + throw ioException; + else throw new IOException(RBEPlugin.getString("No translation found in server response")); + else + throw new IOException(transText.textValue()); + } else for (JsonNode transNode : transText) { sj.add(transNode.path("translatedText").textValue()); }; diff --git a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPage.java b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPage.java index 9561165..0a5ec49 100644 --- a/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPage.java +++ b/eclipse-rbe-plugin/src/com/essiembre/eclipse/rbe/ui/editor/i18n/I18nPage.java @@ -41,6 +41,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import com.essiembre.eclipse.rbe.RBEPlugin; import com.essiembre.eclipse.rbe.model.DeltaEvent; import com.essiembre.eclipse.rbe.model.IDeltaListener; import com.essiembre.eclipse.rbe.model.bundle.Bundle; @@ -73,7 +74,7 @@ public class I18nPage extends ScrolledComposite { private AutoMouseWheelAdapter _autoMouseWheelAdapter; // boolean _autoAdjustNeeded; private Composite _rightComposite; - private Button pushbutton; + private Button translateButton; /** * Constructor. @@ -191,9 +192,10 @@ private void createEditingPart(ScrolledComposite parent) { // } _rightComposite.setLayout(new GridLayout(1, false)); if (!GoogleTranslationCaller.empty(RBEPreferences.getTranslationApiKey())) { - pushbutton = new Button(_rightComposite, SWT.PUSH); - pushbutton.setText("Translate!"); - pushbutton.addSelectionListener(new GoogleTranslationCaller(entryComposites)); + translateButton = new Button(_rightComposite, SWT.PUSH); + translateButton.setText(RBEPlugin.getString("editor.translate")); + translateButton.addSelectionListener(new GoogleTranslationCaller(entryComposites)); + translateButton.setEnabled(false); } entryComposites.clear(); for (Iterator iter = resourceMediator.getLocales().iterator(); @@ -328,6 +330,8 @@ public void refreshTextBoxes() { BundleEntryComposite entryComposite = iter.next(); entryComposite.refresh(key); } + if (translateButton != null) + translateButton.setEnabled(key != null && resourceMediator.getBundleGroup().isKey(key)); } /**