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

org.owasp.webgoat.util.WebGoatI18N Maven / Gradle / Ivy

The newest version!
package org.owasp.webgoat.util;

import java.util.HashMap;
import java.util.Locale;
import java.util.ResourceBundle;

import org.owasp.webgoat.session.WebgoatContext;

@Deprecated
/**
 * 

WebGoatI18N class.

* * @version $Id: $Id * @author dm */ public class WebGoatI18N { private static HashMap labels = new HashMap(); private static Locale currentLocale; private static WebGoatResourceBundleController localeController; /** *

Constructor for WebGoatI18N.

* * @param context a {@link org.owasp.webgoat.session.WebgoatContext} object. */ public WebGoatI18N(WebgoatContext context) { currentLocale = new Locale(context.getDefaultLanguage()); localeController = new WebGoatResourceBundleController(currentLocale); } /** *

loadLanguage.

* * @param language a {@link java.lang.String} object. */ @Deprecated public static void loadLanguage(String language) { // Do nothing } /** *

Setter for the field currentLocale.

* * @param locale a {@link java.util.Locale} object. */ public static void setCurrentLocale(Locale locale) { if (!currentLocale.equals(locale)) { if (!labels.containsKey(locale)) { ResourceBundle resBundle = ResourceBundle.getBundle("WebGoatLabels", locale, localeController); labels.put(locale, resBundle); } WebGoatI18N.currentLocale = locale; } } /** *

get.

* * @param strName a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ public static String get(String strName) { return labels.get(WebGoatI18N.currentLocale).getString(strName); } private static class WebGoatResourceBundleController extends ResourceBundle.Control { private Locale fallbackLocale; public WebGoatResourceBundleController(Locale l) { fallbackLocale = l; } @Override public Locale getFallbackLocale(String baseName, Locale locale) { if(! fallbackLocale.equals(locale)) { return fallbackLocale; } return Locale.ROOT; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy