Skip to content

Commit fd3ac20

Browse files
committed
Align startup language with system locale in policies app
1 parent eb588a5 commit fd3ac20

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

app/src/main/java/org/openimis/imispolicies/MainActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
234234
protected void onCreate(Bundle savedInstanceState) {
235235
global = (Global) getApplicationContext();
236236
super.onCreate(savedInstanceState);
237+
new LanguageManager(this).restoreLanguage(false);
237238
try {
238239
instance = this;
239240
setContentView(R.layout.activity_main);
@@ -582,7 +583,7 @@ public void ShowDialogTex2() {
582583
finish();
583584
});
584585

585-
alertDialogBuilder.show();
586+
alertDialogBuilder.show();
586587
}
587588

588589
public String getMasterDataText2(String fileName, String password) {
@@ -967,4 +968,4 @@ protected void onDestroy() {
967968
instance = null;
968969
super.onDestroy();
969970
}
970-
}
971+
}

app/src/main/java/org/openimis/imispolicies/tools/LanguageManager.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void restoreLanguage() {
7070
* @param withRestart should the current context be restarted (if it's Activity).
7171
*/
7272
public void restoreLanguage(boolean withRestart) {
73-
String language = getStoredLanguage();
73+
String language = resolveStartupLanguage();
7474
setLanguage(language, withRestart);
7575
}
7676

@@ -184,6 +184,14 @@ private String getStoredLanguage() {
184184
return global.getStringKey(Global.PREF_LANGUAGE_KEY, defaultLanguage);
185185
}
186186

187+
private String resolveStartupLanguage() {
188+
String language = getCurrentLocale().getLanguage();
189+
if ("fr".equalsIgnoreCase(language)) {
190+
return "fr";
191+
}
192+
return "en";
193+
}
194+
187195
/**
188196
* @return List of supported languages from tblLanguages
189197
*/

0 commit comments

Comments
 (0)