private Serializable getClosestValue(MLText mlText) { Set<Locale> locales = mlText.getLocales(); Locale contentLocale = I18NUtil.getContentLocale(); Locale locale = I18NUtil.getNearestLocale(contentLocale, locales); if (locale != null) { return mlText.getValue(locale); } // If the content locale is too specific, try relaxing it to just language Locale contentLocaleLang = I18NUtil.getContentLocaleLang(); // We do not expect contentLocaleLang to be null if (contentLocaleLang != null) { locale = I18NUtil.getNearestLocale(contentLocaleLang, locales); if (locale != null) { return mlText.getValue(locale); } } else { logger.warn("contentLocaleLang is null in getClosestValue. This is not expected."); } // Just return the default translation return mlText.getDefaultValue(); }
private Serializable getClosestValue(MLText mlText) { Set<Locale> locales = mlText.getLocales(); Locale contentLocale = I18NUtil.getContentLocale(); Locale locale = I18NUtil.getNearestLocale(contentLocale, locales); if (locale != null) { return mlText.getValue(locale); } // If the content locale is too specific, try relaxing it to just language Locale contentLocaleLang = I18NUtil.getContentLocaleLang(); // We do not expect contentLocaleLang to be null if (contentLocaleLang != null) { locale = I18NUtil.getNearestLocale(contentLocaleLang, locales); if (locale != null) { return mlText.getValue(locale); } } else { logger.warn("contentLocaleLang is null in getClosestValue. This is not expected."); } // Just return the default translation return mlText.getDefaultValue(); }
for (Locale locale : locales) mltext.put(locale, SchemaBootstrap.trimStringForTextFields(mltext.getValue(locale)));
for (Locale locale : locales) mltext.put(locale, SchemaBootstrap.trimStringForTextFields(mltext.getValue(locale)));
rootNodeRef, PROP_QNAME_MULTI_ML_VALUE); assertEquals("Expected 3 MLText values back", 3, checkValues.size()); assertEquals("en_GB text", ((MLText) checkValues.get(0)).getValue(Locale.UK)); assertEquals("en_US text", ((MLText) checkValues.get(1)).getValue(Locale.US)); assertEquals("fr_FR text", ((MLText) checkValues.get(2)).getValue(Locale.FRANCE)); assertEquals("text 1 added using en_US", mlText.getValue(Locale.ENGLISH)); assertEquals("text 2 added using en_US", mlText.getValue(Locale.ENGLISH)); assertEquals("fr_FR text", mlText.getValue(Locale.FRANCE)); assertEquals("text 3 added using en_US", mlText.getValue(Locale.ENGLISH)); assertEquals("text 4 added using en_US", mlText.getValue(Locale.ENGLISH));
BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE); assertEquals(2, ((MLText) textValue).size()); assertEquals("en_GB String", ((MLText) textValue).getValue(Locale.UK)); assertEquals("fr_FR String", ((MLText) textValue).getValue(Locale.FRANCE)); assertEquals("Text wasn't updated correctly", "Not using MLText for this part.", ((MLText) textValue).getValue(Locale.ENGLISH)); assertEquals("Failed to get text using locale it was added with", "Not using MLText for this part.", "Not using MLText for this part.", ((MLText) textValue).getClosestValue(Locale.UK)); assertEquals("fr_FR String", ((MLText) textValue).getValue(Locale.FRANCE));
for (Locale locale : locales) String localeValue = valueMLT.getValue(locale); exporter.startValueMLText(nodeRef, locale, localeValue == null); walkProperty(nodeRef, property, localeValue, -1, parameters, exporter);
for (Locale locale : locales) String localeValue = valueMLT.getValue(locale); exporter.startValueMLText(nodeRef, locale, localeValue == null); walkProperty(nodeRef, property, localeValue, -1, parameters, exporter);