Alexander Wels has uploaded a new change for review. Change subject: userportal,webadmin: split messages in two file ......................................................................
userportal,webadmin: split messages in two file - Split messages.properties into messages and resources so they won't confuse the translation software. Change-Id: I7e5301cb7e4f03f976125b9814f06b28e4f97d5a Signed-off-by: Alexander Wels <aw...@redhat.com> --- M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/branding/BrandingManager.java M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/branding/BrandingTheme.java M packaging/branding/ovirt.brand/branding.properties M packaging/branding/ovirt.brand/messages.properties M packaging/branding/ovirt.brand/messages_de_DE.properties M packaging/branding/ovirt.brand/messages_es_ES.properties M packaging/branding/ovirt.brand/messages_fr_FR.properties M packaging/branding/ovirt.brand/messages_ja_JP.properties M packaging/branding/ovirt.brand/messages_pt_BR.properties M packaging/branding/ovirt.brand/messages_zh_CN.properties A packaging/branding/ovirt.brand/resources.properties 11 files changed, 66 insertions(+), 27 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/18623/1 diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/branding/BrandingManager.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/branding/BrandingManager.java index e125cd3..781bf4a 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/branding/BrandingManager.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/branding/BrandingManager.java @@ -185,23 +185,36 @@ if (messageThemes != null) { for (BrandingTheme theme : messageThemes) { ResourceBundle messagesBundle = theme.getMessagesBundle(locale); - for (String key : messagesBundle.keySet()) { - if (key.startsWith(BRAND_PREFIX + "." + prefix) || key.startsWith(COMMON_PREFIX)) { //$NON-NLS-1$ - // We can potentially override existing values here - // but this is fine as the themes are sorted in order - // And later messages should override earlier ones. - keyValues.put(key.replaceFirst(BRAND_PREFIX + "\\." //$NON-NLS-1$ - + prefix + "\\.", "") //$NON-NLS-1$ - .replaceFirst(COMMON_PREFIX + "\\.", ""), //$NON-NLS-1$ - messagesBundle.getString(key)); - } - } + getKeyValuesFromResourceBundle(prefix, keyValues, messagesBundle); + ResourceBundle resourcesBundle = theme.getResourceBundle(); + getKeyValuesFromResourceBundle(prefix, keyValues, resourcesBundle); } } return keyValues; } /** + * Extract values from the passed resource bundle and put it into the passed in Map based on the prefix passed in. + * @param prefix The prefix to use. + * @param keyValues The {@code Map} to put the values into. + * @param messagesBundle The {@code ResourceBundle} to get the values from. + */ + private void getKeyValuesFromResourceBundle(final String prefix, Map<String, String> keyValues, + ResourceBundle messagesBundle) { + for (String key : messagesBundle.keySet()) { + if (key.startsWith(BRAND_PREFIX + "." + prefix) || key.startsWith(COMMON_PREFIX)) { //$NON-NLS-1$ + // We can potentially override existing values here + // but this is fine as the themes are sorted in order + // And later messages should override earlier ones. + keyValues.put(key.replaceFirst(BRAND_PREFIX + "\\." //$NON-NLS-1$ + + prefix + "\\.", "") //$NON-NLS-1$ + .replaceFirst(COMMON_PREFIX + "\\.", ""), //$NON-NLS-1$ + messagesBundle.getString(key)); + } + } + } + + /** * get a JavaScript associative array string representation of the available messages. Only 'common' messages and * messages that have keys that start with the passed in prefix will be returned. * @param prefix The prefix to use for getting the keys. diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/branding/BrandingTheme.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/branding/BrandingTheme.java index 79bab40..3e0f9bc 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/branding/BrandingTheme.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/branding/BrandingTheme.java @@ -79,9 +79,14 @@ private static final Logger log = Logger.getLogger(BrandingTheme.class); /** - * The key for the resource bundle name. + * The key for the messages resource bundle name. */ private static final String MESSAGES_KEY = "messages"; //$NON-NLS-1$ + + /** + * The key for the resources resource bundle name. + */ + private static final String RESOURCES_KEY = "resources"; //$NON-NLS-1$ /** * The suffix of properties file name. @@ -213,20 +218,41 @@ * @return A {@code ResourceBundle} containing messages. */ public ResourceBundle getMessagesBundle(final Locale locale) { + return getBundle(MESSAGES_KEY, locale); + } + + /** + * Get the theme resources resource bundle. The resource bundle will hold URIs and other values that + * should not get translated. + * @return A {@code ResourceBundle} containing the resources. + */ + public ResourceBundle getResourceBundle() { + return getBundle(RESOURCES_KEY, LocaleFilter.DEFAULT_LOCALE); + } + + /** + * Load the Java resource bundle associated with the passed in Locale and name. + * @param name The name of the {@code ResourceBundle} file. + * @param locale The locale to load. + * @return A {@code ResourceBundle} containing the resources. + */ + private ResourceBundle getBundle(String name, Locale locale) { ResourceBundle result = null; try { File themeDirectory = new File(filePath); URLClassLoader urlLoader = new URLClassLoader( new URL[] { themeDirectory.toURI().toURL() }); - final String messageFileName = brandingProperties.getProperty(MESSAGES_KEY); - String bundleName = messageFileName.lastIndexOf(PROPERTIES_FILE_SUFFIX) != -1 - ? messageFileName.substring(0, messageFileName.lastIndexOf(PROPERTIES_FILE_SUFFIX)) - : messageFileName; - result = ResourceBundle.getBundle(bundleName, locale, urlLoader); + final String messageFileName = brandingProperties.getProperty(name); + if (messageFileName != null) { + String bundleName = messageFileName.lastIndexOf(PROPERTIES_FILE_SUFFIX) != -1 + ? messageFileName.substring(0, messageFileName.lastIndexOf(PROPERTIES_FILE_SUFFIX)) + : messageFileName; + result = ResourceBundle.getBundle(bundleName, locale, urlLoader); + } } catch (IOException e) { // Unable to load messages resource bundle. - log.warn("Unable to read message resource " //$NON-NLS-1$ + log.warn("Unable to read resources resource " //$NON-NLS-1$ + "bundle, returning null", e); //$NON-NLS-1$ } return result; diff --git a/packaging/branding/ovirt.brand/branding.properties b/packaging/branding/ovirt.brand/branding.properties index dcb8ad8..2ecc3e6 100644 --- a/packaging/branding/ovirt.brand/branding.properties +++ b/packaging/branding/ovirt.brand/branding.properties @@ -16,6 +16,8 @@ # text (optional, this overrides the default messages) messages=messages.properties +# URIs, other strings that should not be translated. +resources=resources.properties # Welcome page template (optional, allows you to add things to the welcome page) welcome=welcome_page.template diff --git a/packaging/branding/ovirt.brand/messages.properties b/packaging/branding/ovirt.brand/messages.properties index 52c0c97..7d69e91 100644 --- a/packaging/branding/ovirt.brand/messages.properties +++ b/packaging/branding/ovirt.brand/messages.properties @@ -31,12 +31,9 @@ # The text at the top of the main user page. obrand.webadmin.main_header_label= # Feedback URL -obrand.webadmin.feedback_url=mailto:us...@ovirt.org obrand.webadmin.feedback_link_label=Feedback # Guide URL -obrand.webadmin.guide_url=http://www.ovirt.org/Documentation obrand.webadmin.guide_link_label=Guide -obrand.userportal.guide_url=http://www.ovirt.org/Documentation obrand.userportal.guide_link_label=Guide # The welcome page diff --git a/packaging/branding/ovirt.brand/messages_de_DE.properties b/packaging/branding/ovirt.brand/messages_de_DE.properties index 7dc26fe..8a44e62 100644 --- a/packaging/branding/ovirt.brand/messages_de_DE.properties +++ b/packaging/branding/ovirt.brand/messages_de_DE.properties @@ -9,7 +9,6 @@ obrand.webadmin.application_title=oVirt Engine Web Administration obrand.webadmin.doc=ENGINE Web Administration Dokumentation obrand.webadmin.main_header_label=\ -obrand.webadmin.feedback_url=mailto\:us...@ovirt.org obrand.webadmin.feedback_link_label=Feedback obrand.welcome.header.main=\ obrand.welcome.welcome.text=Willkommen im Virtualization-Manager diff --git a/packaging/branding/ovirt.brand/messages_es_ES.properties b/packaging/branding/ovirt.brand/messages_es_ES.properties index 60ffc3a..afbcdf6 100644 --- a/packaging/branding/ovirt.brand/messages_es_ES.properties +++ b/packaging/branding/ovirt.brand/messages_es_ES.properties @@ -14,7 +14,6 @@ obrand.webadmin.application_title=Administraci\u00F3n de la red de m\u00E1quinas oVirt # auto translated by TM merge from project: oVirt, version: master, DocId: frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/org.ovirt.engine.ui.webadmin.ApplicationConstants obrand.webadmin.doc=Documentaci\u00F3n de administraci\u00F3n de la red ENGINE -obrand.webadmin.feedback_url=mailto\:us...@ovirt.org # auto translated by TM merge from project: oVirt, version: master, DocId: frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/org.ovirt.engine.ui.webadmin.ApplicationConstants obrand.webadmin.feedback_link_label=Comentarios obrand.welcome.welcome.text=Bienvenido al gestor de virtualizaci\u00F3n abierto diff --git a/packaging/branding/ovirt.brand/messages_fr_FR.properties b/packaging/branding/ovirt.brand/messages_fr_FR.properties index dcf1f27..7d6f656 100644 --- a/packaging/branding/ovirt.brand/messages_fr_FR.properties +++ b/packaging/branding/ovirt.brand/messages_fr_FR.properties @@ -11,7 +11,6 @@ obrand.webadmin.application_title=oVirt Engine Web Administration # auto translated by TM merge from project: oVirt, version: master, DocId: frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/org.ovirt.engine.ui.webadmin.ApplicationConstants obrand.webadmin.doc=ENGINE Web Admin Documentation -obrand.webadmin.feedback_url=mailto\:us...@ovirt.org # auto translated by TM merge from project: oVirt, version: master, DocId: frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/org.ovirt.engine.ui.webadmin.ApplicationConstants obrand.webadmin.feedback_link_label=Commentaire obrand.welcome.welcome.text=Bienvenue dans Open Virtualization Manager. diff --git a/packaging/branding/ovirt.brand/messages_ja_JP.properties b/packaging/branding/ovirt.brand/messages_ja_JP.properties index cc4a137..9b37d59 100644 --- a/packaging/branding/ovirt.brand/messages_ja_JP.properties +++ b/packaging/branding/ovirt.brand/messages_ja_JP.properties @@ -7,7 +7,6 @@ obrand.userportal.main_header_label=oVirt Engine obrand.webadmin.application_title=oVirt Engine Web \u7BA1\u7406 obrand.webadmin.doc=Engine Web \u7BA1\u7406\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8 -obrand.webadmin.feedback_url=mailto\:us...@ovirt.org obrand.webadmin.feedback_link_label=\u30D5\u30A3\u30FC\u30C9\u30D0\u30C3\u30AF obrand.welcome.welcome.text=Open Virtualization Manager \u3078\u3088\u3046\u3053\u305D obrand.welcome.version=\u30D0\u30FC\u30B8\u30E7\u30F3 {0} diff --git a/packaging/branding/ovirt.brand/messages_pt_BR.properties b/packaging/branding/ovirt.brand/messages_pt_BR.properties index 4c5f840..48aef5e 100644 --- a/packaging/branding/ovirt.brand/messages_pt_BR.properties +++ b/packaging/branding/ovirt.brand/messages_pt_BR.properties @@ -7,7 +7,6 @@ obrand.userportal.main_header_label=Mecanismo oVirt obrand.webadmin.application_title=Administra\u00E7\u00E3o da Web do Mecansimo oVirt obrand.webadmin.doc=MECANISMO da Documenta\u00E7\u00E3o da Administra\u00E7\u00E3o da Web -obrand.webadmin.feedback_url=mailto\:us...@ovirt.org obrand.webadmin.feedback_link_label=Opini\u00E3o obrand.welcome.welcome.text=Bem-vindo \u00E0 Abrir o Gerenciador de Virtualiza\u00E7\u00E3o. obrand.welcome.version=Vers\u00E3o {0} diff --git a/packaging/branding/ovirt.brand/messages_zh_CN.properties b/packaging/branding/ovirt.brand/messages_zh_CN.properties index 7a241a1..46ad584 100644 --- a/packaging/branding/ovirt.brand/messages_zh_CN.properties +++ b/packaging/branding/ovirt.brand/messages_zh_CN.properties @@ -7,7 +7,6 @@ obrand.userportal.main_header_label=oVirt \u5F15\u64CE obrand.webadmin.application_title=oVirt \u5F15\u64CE\u7684 Web \u7BA1\u7406 obrand.webadmin.doc=ENGINE Web \u7BA1\u7406\u7684\u6587\u6863 -obrand.webadmin.feedback_url=mailto\:us...@ovirt.org obrand.webadmin.feedback_link_label=\u53CD\u9988 obrand.welcome.welcome.text=\u6B22\u8FCE\u4F7F\u7528\u5F00\u653E\u5F0F\u865A\u62DF\u5316\u7BA1\u7406\u8005 obrand.welcome.version=\u7248\u672C {0} diff --git a/packaging/branding/ovirt.brand/resources.properties b/packaging/branding/ovirt.brand/resources.properties new file mode 100644 index 0000000..69ab554 --- /dev/null +++ b/packaging/branding/ovirt.brand/resources.properties @@ -0,0 +1,7 @@ +# Feedback URL +obrand.webadmin.feedback_url=mailto:us...@ovirt.org + +# Guide URL +obrand.webadmin.guide_url=http://www.ovirt.org/Documentation +obrand.userportal.guide_url=http://www.ovirt.org/Documentation + -- To view, visit http://gerrit.ovirt.org/18623 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7e5301cb7e4f03f976125b9814f06b28e4f97d5a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alexander Wels <aw...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches