Update localizations settings

1) now, on « content language » change, it will also change the app language
2) added Esperanto to the list of language in content language
This commit is contained in:
bopol 2020-01-04 21:38:27 +01:00
parent c56fb8cec2
commit dea1e0dcb9
3 changed files with 17 additions and 0 deletions

View File

@ -67,6 +67,7 @@ import org.schabi.newpipe.fragments.list.search.SearchFragment;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.util.Constants;
import org.schabi.newpipe.util.KioskTranslator;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PeertubeHelper;
import org.schabi.newpipe.util.PermissionHelper;
@ -78,6 +79,8 @@ import org.schabi.newpipe.util.ThemeHelper;
import java.util.ArrayList;
import java.util.List;
import static org.schabi.newpipe.util.Localization.changeAppLanguage;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
public static final boolean DEBUG = !BuildConfig.BUILD_TYPE.equals("release");
@ -116,6 +119,8 @@ public class MainActivity extends AppCompatActivity {
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
changeAppLanguage(Localization.getPreferredLocale(getApplicationContext()), getResources());
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

View File

@ -2,8 +2,11 @@ package org.schabi.newpipe.util;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import org.ocpsoft.prettytime.PrettyTime;
import org.ocpsoft.prettytime.units.Decade;
@ -216,4 +219,11 @@ public class Localization {
public static String relativeTime(Calendar calendarTime) {
return getPrettyTime().formatUnrounded(calendarTime);
}
public static void changeAppLanguage(Locale loc, Resources res) {
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.setLocale(loc);
res.updateConfiguration(conf, dm);
}
}

View File

@ -272,6 +272,7 @@
<item>cs</item>
<item>da</item>
<item>de</item>
<item>eo</item>
<item>et</item>
<item>en-GB</item>
<item>en</item>
@ -351,6 +352,7 @@
<item>Čeština</item>
<item>Dansk</item>
<item>Deutsch</item>
<item>Esperanto</item>
<item>Eesti</item>
<item>English (UK)</item>
<item>English (US)</item>