Skip to content

Commit

Permalink
Merge pull request #226 from hash-checker/174
Browse files Browse the repository at this point in the history
2023-07-01 v. 3.7.1: closed #174
  • Loading branch information
fartem committed Jul 1, 2023
2 parents fd542ef + 14fcd8e commit 5be26f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ android {
'ro',
'ru',
'sv',
'pt-rBR',
'zh-rCN',
'vi',
'ja',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum Language implements ListItem {
KO("한국어", "ko"),
NL("Nederlands", "nl"),
PL("Polski", "pl"),
PT("Português (Brasil)", "pt-rBR"),
PT("Português (Brasil)", "pt"),
RO("Română", "ro"),
RU("Русский", "ru"),
SV("Svenska", "sv"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.LocaleList;

import androidx.annotation.NonNull;
import androidx.core.os.LocaleListCompat;

import com.smlnskgmail.jaman.hashchecker.components.locale.api.Language;
import com.smlnskgmail.jaman.hashchecker.components.locale.api.LanguageConfig;
Expand All @@ -32,22 +32,20 @@ public void setLanguage(@NonNull Language language) {

private void setLanguage(@NonNull Context context, @NonNull Language language) {
Locale locale;
if (language != Language.ZH) {
locale = new Locale(language.code(), Locale.getDefault().getCountry());
} else {
if (language == Language.ZH) {
locale = Locale.SIMPLIFIED_CHINESE;
} else if (language == Language.PT) {
locale = new Locale(language.code(), "BR");
} else {
locale = new Locale(language.code(), Locale.getDefault().getCountry());
}

Locale.setDefault(locale);
Configuration config = context.getResources().getConfiguration();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
config.setLocales(new LocaleList(locale));
} else {
config.locale = locale;
}
Configuration configuration = new Configuration();
configuration.locale = locale;

Resources resources = context.getResources();
resources.updateConfiguration(config, resources.getDisplayMetrics());
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
}

@Override
Expand Down

0 comments on commit 5be26f7

Please sign in to comment.