use of er.extensions.localization.ERXLocalizer in project wonder-slim by undur.
the class ERXNumberFormatter method numberFormatterForPattern.
/**
* Returns a shared instance for the specified pattern.
* @return shared instance of formatter
*/
public static NSNumberFormatter numberFormatterForPattern(String pattern) {
NSNumberFormatter formatter;
if (ERXLocalizer.useLocalizedFormatters()) {
ERXLocalizer localizer = ERXLocalizer.currentLocalizer();
formatter = (NSNumberFormatter) localizer.localizedNumberFormatForKey(pattern);
} else {
formatter = _repository.get(pattern);
if (formatter == null) {
formatter = new ERXNumberFormatter(pattern);
_repository.put(pattern, formatter);
}
}
return formatter;
}
use of er.extensions.localization.ERXLocalizer in project wonder-slim by undur.
the class ERXNumberFormatter method setNumberFormatterForPattern.
/**
* Sets a shared instance for the specified pattern.
*/
public static void setNumberFormatterForPattern(NSNumberFormatter formatter, String pattern) {
if (ERXLocalizer.useLocalizedFormatters()) {
ERXLocalizer localizer = ERXLocalizer.currentLocalizer();
localizer.setLocalizedNumberFormatForKey(formatter, pattern);
} else {
if (formatter == null) {
_repository.remove(pattern);
} else {
_repository.put(pattern, formatter);
}
}
}
use of er.extensions.localization.ERXLocalizer in project wonder-slim by undur.
the class ERXTimestampFormatter method dateFormatterForPattern.
/**
* Returns a shared instance for the specified pattern.
*
* @return shared instance of formatter
*/
public static NSTimestampFormatter dateFormatterForPattern(String pattern) {
NSTimestampFormatter formatter;
if (ERXLocalizer.useLocalizedFormatters()) {
ERXLocalizer localizer = ERXLocalizer.currentLocalizer();
formatter = (NSTimestampFormatter) localizer.localizedDateFormatForKey(pattern);
} else {
synchronized (_repository) {
formatter = _repository.get(pattern);
if (formatter == null) {
formatter = new NSTimestampFormatter(pattern);
_repository.put(pattern, formatter);
}
}
}
return formatter;
}
use of er.extensions.localization.ERXLocalizer in project wonder-slim by undur.
the class AjaxDatePicker method localizeStringArray.
private NSArray<String> localizeStringArray(NSArray<String> strings) {
NSMutableArray<String> localizedStrings = new NSMutableArray<>(strings.count());
ERXLocalizer l = ERXLocalizer.currentLocalizer();
for (String string : strings) localizedStrings.add(l.localizedStringForKeyWithDefault(string));
return localizedStrings.immutableClone();
}
use of er.extensions.localization.ERXLocalizer in project wonder-slim by undur.
the class ERXSession method setLanguage.
/**
* Cover method to set the current localizer to the localizer for that
* language.
* <p>
* Also updates languages list with the new single language.
*
* @param language to set the current localizer for.
* @see #language
* @see #setLanguages
*/
public void setLanguage(String language) {
ERXLocalizer newLocalizer = ERXLocalizer.localizerForLanguage(language);
if (!newLocalizer.equals(_localizer)) {
if (_localizer == null && !WOApplication.application().isCachingEnabled())
observer().registerForLocalizationDidResetNotification();
_localizer = newLocalizer;
ERXLocalizer.setCurrentLocalizer(_localizer);
NSMutableArray languageList = new NSMutableArray(_localizer.language());
if (!languageList.containsObject("Nonlocalized"))
languageList.addObject("Nonlocalized");
setLanguages(languageList);
}
}
Aggregations