All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wix.restaurants.helpers.Localizer Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
package com.wix.restaurants.helpers;

import java.util.Locale;
import java.util.Map;

public class Localizer {
    private final String defaultLocale;
    private final String locale;

    public Localizer(Locale defaultLocale, Locale locale) {
        this(defaultLocale.toString(), locale.toString());
    }

    public Localizer(String defaultLocale, String locale) {
        this.defaultLocale = defaultLocale;
        this.locale = locale;
    }

    public String localize(Map multiLocaleString) {
        String localized = multiLocaleString.get(locale);
        if (localized == null) {
            localized = multiLocaleString.get(defaultLocale);
        }
        return ((localized != null) ? localized : "");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy