private String getI18nValue(String translationKey) { return TemplateUtil.getTranslationService().getTranslation(translationKey); } }
private String getI18nValue(String translationKey) { return TemplateUtil.getTranslationService().getTranslation(translationKey); } }
/** * Get all locales that your application supports, all the bundles that you have provided. * @return supported locales */ public Collection<Locale> getSupportedLocales() { Set<Locale> supportedLocales = new HashSet<Locale>(); final TranslationService translationService = TemplateUtil.getTranslationService(); final Collection<String> locales = translationService.getSupportedLocales(); for (String localeKey : locales) { localeKey = localeKey == null ? DEFAULT : localeKey; supportedLocales.add(new Locale(localeKey, translationService.getTranslation(localeKey))); } return supportedLocales; }
/** * Get all locales that your application supports, all the bundles that you have provided. * @return supported locales */ public Collection<Locale> getSupportedLocales() { Set<Locale> supportedLocales = new HashSet<Locale>(); final TranslationService translationService = TemplateUtil.getTranslationService(); final Collection<String> locales = translationService.getSupportedLocales(); for (String localeKey : locales) { localeKey = localeKey == null ? DEFAULT : localeKey; supportedLocales.add(new Locale(localeKey, translationService.getTranslation(localeKey))); } return supportedLocales; }
@Override public Object getKey(Locale item) { final String activeLocale = TemplateUtil.getTranslationService().getActiveLocale(); String defaultLanguage = activeLocale != null ? activeLocale : LocaleSelector.DEFAULT; return item == null || item.getLocale() == null ? defaultLanguage : item.getLocale(); } }
@Override public Object getKey(Locale item) { final String activeLocale = TemplateUtil.getTranslationService().getActiveLocale(); String defaultLanguage = activeLocale != null ? activeLocale : LocaleSelector.DEFAULT; return item == null || item.getLocale() == null ? defaultLanguage : item.getLocale(); } }
/** * Called to perform i18n translation on the given template. Add i18n-prefix attribute to root of * template to allow translation after bean creation. * * @param templateRoot */ public static void translateTemplate(final String templateFile, final Element templateRoot) { if (!getTranslationService().isEnabled()) return; logger.finer("Translating template: " + templateFile); final String i18nKeyPrefix = getI18nPrefix(templateFile); // Add i18n prefix attribute for post-creation translation templateRoot.setAttribute("data-i18n-prefix", i18nKeyPrefix); DomVisit.visit(new ElementWrapper(templateRoot), new TemplateTranslationVisitor(i18nKeyPrefix)); }
/** * Called to perform i18n translation on the given template. Add i18n-prefix attribute to root of * template to allow translation after bean creation. * * @param templateRoot */ public static void translateTemplate(final String templateFile, final Element templateRoot) { if (!getTranslationService().isEnabled()) return; logger.finer("Translating template: " + templateFile); final String i18nKeyPrefix = getI18nPrefix(templateFile); // Add i18n prefix attribute for post-creation translation templateRoot.setAttribute("data-i18n-prefix", i18nKeyPrefix); DomVisit.visit(new ElementWrapper(templateRoot), new TemplateTranslationVisitor(i18nKeyPrefix)); }