Example usage for java.util Locale setDefault

List of usage examples for java.util Locale setDefault

Introduction

In this page you can find the example usage for java.util Locale setDefault.

Prototype

public static synchronized void setDefault(Locale newLocale) 

Source Link

Document

Sets the default locale for this instance of the Java Virtual Machine.

Usage

From source file:edu.ku.brc.specify.config.init.SpecifyDBSetupWizardFrame.java

/**
 * @param args//from   w  ww.  j  a v  a 2  s .com
 */
public static void main(String[] args) {
    // Set App Name, MUST be done very first thing!
    UIRegistry.setAppName("Specify"); //$NON-NLS-1$

    try {
        ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$

    } catch (MissingResourceException ex) {
        Locale.setDefault(Locale.ENGLISH);
        UIRegistry.setResourceLocale(Locale.ENGLISH);
    }

    try {
        if (!System.getProperty("os.name").equals("Mac OS X")) {
            UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
            PlasticLookAndFeel.setPlasticTheme(new DesertBlue());
        }
    } catch (Exception e) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSetupWizard.class, e);
        e.printStackTrace();
    }

    AppBase.processArgs(args);
    AppBase.setupTeeForStdErrStdOut(true, false);

    System.setProperty("appdatadir", "..");

    // Then set this
    IconManager.setApplicationClass(Specify.class);
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$
    IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$

    // Load Local Prefs
    AppPreferences localPrefs = AppPreferences.getLocalPrefs();
    //try {
    //System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+(new File(UIRegistry.getAppDataDir()).getCanonicalPath())+"]");
    //} catch (IOException ex) {}

    localPrefs.setDirPath(UIRegistry.getAppDataDir());

    // Check to see if we should check for a new version
    if (localPrefs.getBoolean(VERSION_CHECK, null) == null) {
        localPrefs.putBoolean(VERSION_CHECK, true);
    }

    if (localPrefs.getBoolean(EXTRA_CHECK, null) == null) {
        localPrefs.putBoolean(EXTRA_CHECK, true);
    }

    if (UIHelper.isLinux()) {
        Specify.checkForSpecifyAppsRunning();
    }

    if (UIRegistry.isEmbedded()) {
        ProcessListUtil.checkForMySQLProcesses(new ProcessListener() {
            @Override
            public void done(PROC_STATUS status) // called on the UI thread
            {
                if (status == PROC_STATUS.eOK || status == PROC_STATUS.eFoundAndKilled) {
                    startupContinuing();
                }
            }
        });
    } else {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                startupContinuing();
            }
        });
    }
}

From source file:Main.java

public static void setLocale(final Context ctx, final String lang) {
    final Locale loc = new Locale(lang);
    Locale.setDefault(loc);
    final Configuration cfg = new Configuration();
    cfg.locale = loc;//from  w  w w.j  ava  2 s .c o m
    ctx.getResources().updateConfiguration(cfg, null);
}

From source file:Main.java

private static void updateResources(Context context, String language) {
    Locale locale = new Locale(language);
    Locale.setDefault(locale);

    Resources resources = context.getResources();

    Configuration configuration = new Configuration(resources.getConfiguration());

    configuration.locale = locale;/*from   w w  w .j a v  a 2 s.  co m*/

    resources.updateConfiguration(configuration, resources.getDisplayMetrics());
}

From source file:Main.java

public static void setLanguge(Context ctx, String languageToLoad) {
    Locale locale = new Locale(languageToLoad);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;//from   ww  w. j a va 2s.  co  m
    ctx.getResources().updateConfiguration(config, ctx.getResources().getDisplayMetrics());
}

From source file:Main.java

public static String buildIdentificationNumberWithDecimalSeparator(CharSequence number) {
    if (number.length() == 0) {
        return number.toString();
    }/*from   w ww  .  j  ava 2s  . co m*/
    try {
        Long value = Long.valueOf(number.toString());
        Locale.setDefault(Locale.GERMAN);
        return String.format("%,d", value);
    } catch (NumberFormatException e) {
        return "";
    }
}

From source file:Main.java

public static void updateResources(Context context, String language) {
    //set the language of the app
    Locale locale = new Locale(language);
    Locale.setDefault(locale);

    Resources resources = context.getResources();

    Configuration configuration = resources.getConfiguration();
    configuration.locale = locale;/*from   w  ww  .j  a va  2s .  c  o  m*/

    resources.updateConfiguration(configuration, resources.getDisplayMetrics());
}

From source file:Main.java

private static void updateResources(Context context, String language) {
    Locale locale = new Locale(language);
    Locale.setDefault(locale);

    Resources resources = context.getResources();

    Configuration configuration = resources.getConfiguration();
    configuration.locale = locale;/*from   w  w w  . j  a va  2 s .  c  o m*/

    resources.updateConfiguration(configuration, resources.getDisplayMetrics());
}

From source file:Main.java

/**
 * Update language/*w  ww .  j av a  2  s  . co  m*/
 * 
 * @param code The language code. Like: en, cz, iw, ...
 */
public static void updateLanguage(Context context, String code) {
    Locale locale = new Locale(code);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
}

From source file:Main.java

/**
 * Change the default locale of the application for this activity
 *
 * @param locale To set in the configuration
 *//*from   w w  w  . j ava  2  s  .  co  m*/
public static void setDefaultLocale(Context context, String locale) {
    Locale locJa = new Locale(locale);
    Locale.setDefault(locJa);

    Configuration config = new Configuration();
    config.locale = locJa;

    if (context != null) {
        context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
    }
}

From source file:Main.java

/**
 * Prepares the locale. The language can be overridden with the specified environment variable. Set it to "de" to
 * enforce German language for example. The default is the system locale.
 *
 * @param overrideEnvVar/*from  w  ww  . j av a 2s  .  c  o  m*/
 *            The environment variable to check for override value. Must not be null.
 */

public static void prepareLocale(final String overrideEnvVar) {
    final String language = System.getenv().get(overrideEnvVar);
    if (language != null) {
        Locale.setDefault(new Locale(language));
    }
}