Skip to content

Commit

Permalink
Address Guillaume's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Oct 18, 2024
1 parent 2d8ba3e commit d4a78de
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public boolean getAsBoolean() {
*/
@Deprecated
public static String nativeImageUserLanguage(NativeConfig nativeConfig, LocalesBuildTimeConfig localesBuildTimeConfig) {
String language = LocalesBuildTimeConfig.DEFAULT_LANGUAGE;
String language = System.getProperty("user.language", "en");
if (localesBuildTimeConfig.defaultLocale.isPresent()) {
language = localesBuildTimeConfig.defaultLocale.get().getLanguage();
}
Expand All @@ -140,7 +140,7 @@ public static String nativeImageUserLanguage(NativeConfig nativeConfig, LocalesB
*/
@Deprecated
public static String nativeImageUserCountry(NativeConfig nativeConfig, LocalesBuildTimeConfig localesBuildTimeConfig) {
String country = LocalesBuildTimeConfig.DEFAULT_COUNTRY;
String country = System.getProperty("user.country", "");
if (localesBuildTimeConfig.defaultLocale.isPresent()) {
country = localesBuildTimeConfig.defaultLocale.get().getCountry();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public void write(String s, byte[] bytes) {
overallCatch.invokeStaticMethod(BUILD_TIME_INITIALIZATION,
overallCatch.marshalAsArray(String.class, overallCatch.load(""))); // empty string means initialize everything

// Set the user.language and user.country system properties to the default locale
// The deprecated option takes precedence for users who are already using it.
if (nativeConfig.userLanguage().isPresent()) {
overallCatch.invokeStaticMethod(REGISTER_RUNTIME_SYSTEM_PROPERTIES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class LocalesBuildTimeConfig {
* Defaults to the JVM's default locale if not set. Starting with GraalVM for JDK 24, it defaults to {@code en-US}
* for native executables.
*/
@ConfigItem(defaultValue = DEFAULT_LANGUAGE + "-" + DEFAULT_COUNTRY, defaultValueDocumentation = "Build system locale")
@ConfigItem(defaultValueDocumentation = "Defaults to the JVM's default locale if not set. "
+ "Starting with GraalVM for JDK 24, it defaults to en-US for native executables.")
public Optional<Locale> defaultLocale;
}

0 comments on commit d4a78de

Please sign in to comment.