0

How can I make my app to ignore certains configurations, for example, the device's language (forcint the app to use default strings)

For better understanding thats the concret problem:

I have a Android Library project with some strings in the strings.xml file

That library have the strings in english, german, french and spanish.

I want use the library in an app but this app only supports english and german so I'd like to ignore the strings provided by the library project in french and spanish in order to avoid a partial traduction

Is that possible without magical workarrounds?

Thanks

Addev
  • 31,819
  • 51
  • 183
  • 302

2 Answers2

1

You can get the system Locale using this code

Locale.getDefault().getLanguage();

You can check if it's French or Spanish then you can enforce your own locale either English or German

Locale locale = new Locale("en");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
      getBaseContext().getResources().getDisplayMetrics()); 

some of the code taken from Set Locale programmatically

Community
  • 1
  • 1
Sharjeel
  • 15,588
  • 14
  • 58
  • 89
0

When you publish your app to the Market, you can select which markets to ship to.

Karim Varela
  • 7,562
  • 10
  • 53
  • 78