Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
naotoj committed Oct 18, 2024
1 parent c34fb2c commit 3dbdbcd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
27 changes: 5 additions & 22 deletions src/java.base/share/classes/java/util/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -1126,28 +1126,11 @@ private static synchronized Locale getFormatLocale() {
}

private static Locale initDefault() {
String language, region, script, country, variant;
language = StaticProperty.USER_LANGUAGE;
// for compatibility, check for old user.region property
region = StaticProperty.USER_REGION;
if (!region.isEmpty()) {
// region can be of form country, country_variant, or _variant
int i = region.indexOf('_');
if (i >= 0) {
country = region.substring(0, i);
variant = region.substring(i + 1);
} else {
country = region;
variant = "";
}
script = "";
} else {
script = StaticProperty.USER_SCRIPT;
country = StaticProperty.USER_COUNTRY;
variant = StaticProperty.USER_VARIANT;
}

return getInstance(language, script, country, variant,
return getInstance(
StaticProperty.USER_LANGUAGE,
StaticProperty.USER_SCRIPT,
StaticProperty.USER_COUNTRY,
StaticProperty.USER_VARIANT,
getDefaultExtensions(StaticProperty.USER_EXTENSIONS)
.orElse(null));
}
Expand Down
22 changes: 18 additions & 4 deletions src/java.base/share/classes/jdk/internal/util/StaticProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,33 @@ private StaticProperty() {}
USER_LANGUAGE = getProperty(props, "user.language", "en");
USER_LANGUAGE_DISPLAY = getProperty(props, "user.language.display", USER_LANGUAGE);
USER_LANGUAGE_FORMAT = getProperty(props, "user.language.format", USER_LANGUAGE);
USER_SCRIPT = getProperty(props, "user.script", "");
// for compatibility, check for old user.region property
USER_REGION = getProperty(props, "user.region", "");
if (!USER_REGION.isEmpty()) {
// region can be of form country, country_variant, or _variant
int i = USER_REGION.indexOf('_');
if (i >= 0) {
USER_COUNTRY = USER_REGION.substring(0, i);
USER_VARIANT = USER_REGION.substring(i + 1);
} else {
USER_COUNTRY = USER_REGION;
USER_VARIANT = "";
}
USER_SCRIPT = "";
} else {
USER_SCRIPT = getProperty(props, "user.script", "");
USER_COUNTRY = getProperty(props, "user.country", "");
USER_VARIANT = getProperty(props, "user.variant", "");
}
USER_SCRIPT_DISPLAY = getProperty(props, "user.script.display", USER_SCRIPT);
USER_SCRIPT_FORMAT = getProperty(props, "user.script.format", USER_SCRIPT);
USER_COUNTRY = getProperty(props, "user.country", "");
USER_COUNTRY_DISPLAY = getProperty(props, "user.country.display", USER_COUNTRY);
USER_COUNTRY_FORMAT = getProperty(props, "user.country.format", USER_COUNTRY);
USER_VARIANT = getProperty(props, "user.variant", "");
USER_VARIANT_DISPLAY = getProperty(props, "user.variant.display", USER_VARIANT);
USER_VARIANT_FORMAT = getProperty(props, "user.variant.format", USER_VARIANT);
USER_EXTENSIONS = getProperty(props, "user.extensions", "");
USER_EXTENSIONS_DISPLAY = getProperty(props, "user.extensions.display", USER_EXTENSIONS);
USER_EXTENSIONS_FORMAT = getProperty(props, "user.extensions.format", USER_EXTENSIONS);
USER_REGION = getProperty(props, "user.region", "");
}

private static String getProperty(Properties props, String key) {
Expand Down

0 comments on commit 3dbdbcd

Please sign in to comment.