Skip to content

Commit 66237ab

Browse files
committed
KeepAndroidOpen: Choose website language from list of supported languages
1 parent 06e4548 commit 66237ab

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

app/src/main/java/org/schabi/newpipe/MainActivity.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,21 @@ private void showKeepAndroidDialog() {
988988
0
989989
));
990990

991-
final var kaoURI = Uri.parse("https://keepandroidopen.org");
991+
final var supportedLannguages = List.of("fr", "de", "ca", "es", "id", "it", "pl",
992+
"pt", "cs", "sk", "fa", "ar", "tr", "el", "th", "ru", "uk", "ko", "zh", "ja");
993+
final var locale = Localization.getAppLocale();
994+
final String kaoBaseUrl = "https://keepandroidopen.org/";
995+
final String kaoURIString;
996+
if (supportedLannguages.contains(locale.getLanguage())) {
997+
if ("zh".equals(locale.getLanguage())) {
998+
kaoURIString = kaoBaseUrl + ("TW".equals(locale.getCountry()) ? "zh-TW" : "zh-CN");
999+
} else {
1000+
kaoURIString = kaoBaseUrl + locale.getLanguage();
1001+
}
1002+
} else {
1003+
kaoURIString = kaoBaseUrl;
1004+
}
1005+
final var kaoURI = Uri.parse(kaoURIString);
9921006
final var solutionURI = Uri.parse(
9931007
"https://github.com/woheller69/FreeDroidWarn?tab=readme-ov-file#solutions");
9941008

@@ -1009,7 +1023,7 @@ private void showKeepAndroidDialog() {
10091023
.setNegativeButton(this.getString(R.string.kao_dialog_more_info), null)
10101024
.show();
10111025

1012-
// If we use setNeutralButton and etc. dialog will close after pressing the buttons
1026+
// If we use setNeutralButton and etc. dialog will close after pressing the buttons,
10131027
// but we want it to close only when positive button is pressed
10141028
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(v ->
10151029
this.startActivity(new Intent(Intent.ACTION_VIEW, kaoURI))

0 commit comments

Comments
 (0)