diff --git a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java index 60c3589..a733fca 100644 --- a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java @@ -19,12 +19,15 @@ package net.schueller.peertube.activity; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceManager; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; +import java.util.Locale; + import static net.schueller.peertube.helper.Constants.DEFAULT_THEME; import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; @@ -45,6 +48,21 @@ public class CommonActivity extends AppCompatActivity { "style", getPackageName()) ); + + // Set language + String countryCode=sharedPref.getString("pref_language_app","en"); + Locale locale=new Locale(countryCode);; + //Neither Chinese language choice was working, found this fix on stack overflow + if(countryCode.equals("zh-rCN")) + locale = Locale.SIMPLIFIED_CHINESE; + if(countryCode.equals("zh-rTW")) + locale = Locale.TRADITIONAL_CHINESE; + + Locale.setDefault(locale); + Configuration config = getBaseContext().getResources().getConfiguration(); + config.locale = locale; + getBaseContext().getResources().updateConfiguration(config, + getBaseContext().getResources().getDisplayMetrics()); } } diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index 5936a02..8a7d9f6 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -433,6 +433,58 @@ za zu + + + ar + bn + cs + de + el + en + es + fa + fi + fr + gd + hi + it + ja + no + nl + pl + ru + sv + tr + zh-rCN + zh-rTW + + + + @string/ar + @string/bn + @string/cs + @string/de + @string/el + @string/en + @string/es + @string/fa + @string/fi + @string/fr + @string/gd + @string/hi + @string/it + @string/ja + @string/no + @string/nl + @string/pl + @string/ru + @string/sv + @string/tr + @string/zh + @string/tw + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ef83c3a..b64e99e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -60,9 +60,10 @@ PeerTube Server Background Playback If enabled, continues to play video in background. + Application Language + Select language for application interface. Restart app for change to take effect. Pause on back button Pause background play when pressing back during video playback. - Abkhazian Afar diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index a6d4e93..e7c3dd8 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -30,6 +30,15 @@ android:summary="@string/pref_description_back_pause" android:title="@string/pref_title_back_pause" /> + + /> +