Skip to content

Commit 2e88a8c

Browse files
pesseSamuel Nitsche
authored andcommitted
Add NLS_LANG to the list of environment variables which can change the cli locale
1 parent f660875 commit 2e88a8c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The latest CLI is always compatible with all database frameworks of the same min
2828
For example CLI-3.0.4 is compatible with database framework 3.0.0-3.0.4 but not with database framework 2.x and 3.1.x.
2929

3030
## Localization and NLS settings
31-
utPLSQL-cli will use the environment variables "LC_ALL" or "LANG" to change the locale and therefore the NLS settings.
31+
utPLSQL-cli will use the environment variables (in that order) "NLS_LANG", "LC_ALL" or "LANG" to change the locale and therefore the NLS settings.
3232
If neither environment variable is available, it will use the JVM default locale.
3333

3434
Example: to change the NLS-settings to English American, you can do the following:

src/main/java/org/utplsql/cli/LocaleInitializer.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
/** This class makes sure the java locale is set according to the environment variables LC_ALL and LANG
88
* We experienced that, in some cases, the locale was not set as expected, therefore this class implements some clear
99
* rules:
10-
* 1. If environment variable LC_ALL is set, we try to parse its content and set locale according to its value if valid
11-
* 2. If environment variable LANG is set, we try to parse its content and set locale according to its value if valid
12-
* 3. Otherwise we use default locale
10+
* 1. If environment variable NLS_LANG is set, we try to parse its content and set locale according to its value if valid
11+
* 2. If environment variable LC_ALL is set, we try to parse its content and set locale according to its value if valid
12+
* 3. If environment variable LANG is set, we try to parse its content and set locale according to its value if valid
13+
* 4. Otherwise we use default locale
1314
*
1415
* @author pesse
1516
*/
@@ -21,7 +22,12 @@ class LocaleInitializer {
2122
*
2223
*/
2324
static void initLocale() {
24-
if ( !setDefaultLocale(System.getenv("LC_ALL")))
25+
26+
boolean localeChanged = setDefaultLocale(System.getenv("NLS_LANG"));
27+
28+
if ( !localeChanged )
29+
localeChanged = setDefaultLocale(System.getenv("LC_ALL"));
30+
if ( !localeChanged )
2531
setDefaultLocale(System.getenv("LANG"));
2632
}
2733

0 commit comments

Comments
 (0)