Language can be changed, doesn't refresh automatically yet
This commit is contained in:
@@ -70,7 +70,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
*/
|
||||
private String loadLocale(){
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("Settings", Activity.MODE_PRIVATE);
|
||||
return sharedPreferences.getString("Language", "");
|
||||
return sharedPreferences.getString("Language", "nl");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Locale.setDefault(locale);
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.setLocale(locale);
|
||||
getBaseContext().getResources().getConfiguration().updateFrom(configuration);
|
||||
getBaseContext().getResources().updateConfiguration(configuration, getBaseContext().getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,8 @@ public class SettingsFragment extends Fragment {
|
||||
languageDropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
setLocale(dropdownPositionToLanguage(position));
|
||||
setLocale(dropdownPositionToLanguage(id));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,11 +68,11 @@ public class SettingsFragment extends Fragment {
|
||||
|
||||
/**
|
||||
* converts the languageDropdown position to the belonging language
|
||||
* @param position desired position to convert
|
||||
* @param id desired position to convert
|
||||
* @return the language belonging to the position of the languageDropdown
|
||||
*/
|
||||
private String dropdownPositionToLanguage(int position) {
|
||||
switch (position){
|
||||
private String dropdownPositionToLanguage(long id) {
|
||||
switch ((int) id){
|
||||
case 0:
|
||||
return "nl";
|
||||
case 1:
|
||||
@@ -106,7 +107,7 @@ public class SettingsFragment extends Fragment {
|
||||
Locale.setDefault(locale);
|
||||
Configuration config = new Configuration();
|
||||
config.setLocale(locale);
|
||||
getContext().getResources().getConfiguration().updateFrom(config);
|
||||
getContext().getResources().updateConfiguration(config, getContext().getResources().getDisplayMetrics());
|
||||
editor.putString("Language", language);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
20
app/src/main/res/values-nl/strings.xml
Normal file
20
app/src/main/res/values-nl/strings.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name" translatable="false">Next Location</string>
|
||||
<string name="locations">Locaties</string>
|
||||
<string name="routes">Routes</string>
|
||||
<string name="statistics">Statistieken</string>
|
||||
<string name="settings">Instellingen</string>
|
||||
<string name="language">Taal</string>
|
||||
<string name="imperial_system">Imperiaal systeem</string>
|
||||
<string name="_65_mode">65+ stand</string>
|
||||
<string name="colorblind">Kleurenblind</string>
|
||||
<string name="total_distance">Totale afstand:</string>
|
||||
<string name="visited_locations">Bezochte locaties:</string>
|
||||
<string name="total_time">Totale tijd:</string>
|
||||
<string name="coupons_collected">Coupons gespaard:</string>
|
||||
<string name="coupons">Coupons</string>
|
||||
<string name="start_route">Start Route</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user