Search in sources :

Example 1 with ERXLocalizer

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;
}
Also used : NSNumberFormatter(com.webobjects.foundation.NSNumberFormatter) ERXLocalizer(er.extensions.localization.ERXLocalizer)

Example 2 with ERXLocalizer

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);
        }
    }
}
Also used : ERXLocalizer(er.extensions.localization.ERXLocalizer)

Example 3 with ERXLocalizer

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;
}
Also used : ERXLocalizer(er.extensions.localization.ERXLocalizer) NSTimestampFormatter(com.webobjects.foundation.NSTimestampFormatter)

Example 4 with ERXLocalizer

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();
}
Also used : NSMutableArray(com.webobjects.foundation.NSMutableArray) ERXLocalizer(er.extensions.localization.ERXLocalizer)

Example 5 with ERXLocalizer

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);
    }
}
Also used : NSMutableArray(com.webobjects.foundation.NSMutableArray) ERXLocalizer(er.extensions.localization.ERXLocalizer)

Aggregations

ERXLocalizer (er.extensions.localization.ERXLocalizer)7 NSMutableArray (com.webobjects.foundation.NSMutableArray)2 NSNumberFormatter (com.webobjects.foundation.NSNumberFormatter)1 NSTimestampFormatter (com.webobjects.foundation.NSTimestampFormatter)1