Adding configuration setting and supporting code to choose language (#168)
This commit is contained in:
parent
18fd3a2384
commit
6ad310c398
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -433,6 +433,58 @@
|
||||
<item>za</item>
|
||||
<item>zu</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="supportedLanguagesValues">
|
||||
<item>ar</item>
|
||||
<item>bn</item>
|
||||
<item>cs</item>
|
||||
<item>de</item>
|
||||
<item>el</item>
|
||||
<item>en</item>
|
||||
<item>es</item>
|
||||
<item>fa</item>
|
||||
<item>fi</item>
|
||||
<item>fr</item>
|
||||
<item>gd</item>
|
||||
<item>hi</item>
|
||||
<item>it</item>
|
||||
<item>ja</item>
|
||||
<item>no</item>
|
||||
<item>nl</item>
|
||||
<item>pl</item>
|
||||
<item>ru</item>
|
||||
<item>sv</item>
|
||||
<item>tr</item>
|
||||
<item>zh-rCN</item>
|
||||
<item>zh-rTW</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name = "supportedLanguagesArray">
|
||||
<item>@string/ar</item>
|
||||
<item>@string/bn</item>
|
||||
<item>@string/cs</item>
|
||||
<item>@string/de</item>
|
||||
<item>@string/el</item>
|
||||
<item>@string/en</item>
|
||||
<item>@string/es</item>
|
||||
<item>@string/fa</item>
|
||||
<item>@string/fi</item>
|
||||
<item>@string/fr</item>
|
||||
<item>@string/gd</item>
|
||||
<item>@string/hi</item>
|
||||
<item>@string/it</item>
|
||||
<item>@string/ja</item>
|
||||
<item>@string/no</item>
|
||||
<item>@string/nl</item>
|
||||
<item>@string/pl</item>
|
||||
<item>@string/ru</item>
|
||||
<item>@string/sv</item>
|
||||
<item>@string/tr</item>
|
||||
<item>@string/zh</item>
|
||||
<item>@string/tw</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="empty_array"/>
|
||||
|
||||
<string-array name="quality">
|
||||
|
@ -60,9 +60,10 @@
|
||||
<string name="pref_title_peertube_server">PeerTube Server</string>
|
||||
<string name="pref_title_background_play">Background Playback</string>
|
||||
<string name="pref_description_background_play">If enabled, continues to play video in background.</string>
|
||||
<string name="pref_language_app">Application Language</string>
|
||||
<string name="pref_description_language_app">Select language for application interface. Restart app for change to take effect.</string>
|
||||
<string name="pref_title_back_pause">Pause on back button</string>
|
||||
<string name="pref_description_back_pause">Pause background play when pressing back during video playback.</string>
|
||||
|
||||
<!-- languages -->
|
||||
<string name="ab">Abkhazian</string>
|
||||
<string name="aa">Afar</string>
|
||||
|
@ -30,6 +30,15 @@
|
||||
android:summary="@string/pref_description_back_pause"
|
||||
android:title="@string/pref_title_back_pause" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@array/empty_array"
|
||||
android:entries="@array/supportedLanguagesArray"
|
||||
android:entryValues="@array/supportedLanguagesValues"
|
||||
android:key="pref_language_app"
|
||||
android:summary="@string/pref_description_language_app"
|
||||
android:title="@string/pref_language_app" />
|
||||
/>
|
||||
|
||||
<ListPreference
|
||||
android:title="@string/pref_title_app_theme"
|
||||
android:summary="@string/pref_description_app_theme"
|
||||
|
Loading…
Reference in New Issue
Block a user