public static Locale getLocale() { Locale rtn = threadLocales.get(); if ( rtn != null ) { return rtn; } setLocale( langChoice.getDefaultLocale() ); return langChoice.getDefaultLocale(); }
public static final LanguageChoice getInstance() { if ( choice != null ) { return choice; } choice = new LanguageChoice(); return choice; }
public void saveSettings() { try { Properties properties = new Properties(); properties.setProperty( STRING_DEFAULT_LOCALE, defaultLocale.toString() ); properties.store( new FileOutputStream( getSettingsFilename() ), "Language Choice" ); } catch ( IOException e ) { // Ignore } }
continue; String name = per.getDisplayName( LanguageChoice.getInstance().getDefaultLocale() ); PerspectiveData perspectiveData = new PerspectiveData( name, per.getId() ); if ( Arrays.asList( defaultDisabled ).contains( per.getId() ) ) {
@Override protected void after() { cleanUp(); System.setProperties( originalProperties ); Locale.setDefault( originalLocale ); Locale.setDefault( Locale.Category.FORMAT, originalFormatLocale ); LanguageChoice.getInstance().setDefaultLocale( originalLocale ); TimeZone.setDefault( originalTimezone ); FileUtils.deleteQuietly( tmpKettleHome.toFile() ); }
LanguageChoice.getInstance().setDefaultLocale( EnvUtil.createLocale( defaultLocale ) ); LanguageChoice.getInstance().saveSettings();
private LanguageChoice() { try { loadSettings(); } catch ( IOException e ) { // Can't load settings: set the default defaultLocale = Const.DEFAULT_LOCALE; if ( defaultLocale.getLanguage().equals( Locale.GERMAN.getLanguage() ) ) { defaultLocale = Locale.US; } } }
addLineToBuilder( stepTree, LanguageChoice.getInstance().getDefaultLocale() ); final StringBuilder stepCountPerCategory = new StringBuilder(); addLineToBuilder( stepCountPerCategory, LanguageChoice.getInstance().getDefaultLocale() );
@Override protected void before() throws Throwable { originalProperties = System.getProperties(); System.setProperties( copyOf( originalProperties ) ); originalLocale = Locale.getDefault(); originalFormatLocale = Locale.getDefault( Locale.Category.FORMAT ); originalTimezone = TimeZone.getDefault(); TimeZone.setDefault( TimeZone.getTimeZone( "UTC" ) ); Locale.setDefault( Locale.US ); Locale.setDefault( Locale.Category.FORMAT, Locale.US ); LanguageChoice.getInstance().setDefaultLocale( Locale.US ); tmpKettleHome = Files.createTempDirectory( Long.toString( System.nanoTime() ) ); System.setProperty( "file.encoding", "UTF-8" ); System.setProperty( "user.timezone", "UTC" ); System.setProperty( "KETTLE_HOME", tmpKettleHome.toString() ); System.setProperty( Const.KETTLE_DISABLE_CONSOLE_LOGGING, "Y" ); System.clearProperty( Const.VFS_USER_DIR_IS_ROOT ); System.clearProperty( Const.KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION ); System.clearProperty( Const.KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE ); System.clearProperty( Const.KETTLE_DEFAULT_INTEGER_FORMAT ); System.clearProperty( Const.KETTLE_DEFAULT_NUMBER_FORMAT ); System.clearProperty( Const.KETTLE_DEFAULT_BIGNUMBER_FORMAT ); System.clearProperty( Const.KETTLE_DEFAULT_DATE_FORMAT ); System.clearProperty( Const.KETTLE_DEFAULT_TIMESTAMP_FORMAT ); System.clearProperty( Const.KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL ); defaultInit(); }
LanguageChoice.getInstance().getDefaultLocale().toString(), GlobalMessages.localeCodes ); if ( idxDefault >= 0 ) { wDefaultLocale.select( idxDefault );
/** * Returns a {@link LinkedHashSet} of {@link Locale}s for consideration when localizing text. The * {@link LinkedHashSet} contains the user selected preferred {@link Locale}, the failover {@link Locale} * ({@link Locale#ENGLISH}) and the {@link Locale#ROOT}. * * @return Returns a {@link LinkedHashSet} of {@link Locale}s for consideration when translating text */ public static LinkedHashSet<Locale> getActiveLocales() { // Use a LinkedHashSet to maintain order final LinkedHashSet<Locale> activeLocales = new LinkedHashSet<>(); // Example: messages_fr_FR.properties activeLocales.add( langChoice.getDefaultLocale() ); // Example: messages_en_US.properties activeLocales.add( FAILOVER_LOCALE ); // Example: messages.properties activeLocales.add( Locale.ROOT ); return activeLocales; }
private void loadSettings() throws IOException { Properties properties = new Properties(); FileInputStream fis = new FileInputStream( getSettingsFilename() ); try { properties.load( fis ); } finally { try { fis.close(); } catch ( IOException ignored ) { // Ignore closure exceptions } } String defaultLocaleStr = properties.getProperty( STRING_DEFAULT_LOCALE, Const.DEFAULT_LOCALE.toString() ); defaultLocale = EnvUtil.createLocale( defaultLocaleStr ); }