question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Application context resources not localized after a runtime locale change

See original GitHub issue
getString(R.string.main_activity_title) - always returns valid string as expected
applicationContext.getString(R.string.main_activity_title) - returns only initial locale string

Could you provide any information on this issue?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gunhansancarcommented, Oct 1, 2020

When I have more time, I’ll try to add a listener approach to notify changes to the static classes.

If you’re using Dagger, you could provide Activity context to your resourcemanager using custom scopes. That way it can be consumed in ViewModel without leaking the context. However, it is more about the dagger modules/components.

0reactions
Tamekicommented, Oct 1, 2020

Ok, got it 😃 Thanks for response) I assume that It would be cool to add a note about using applicationContext to get resources in README.md to decrease miss understanding or link to this issue)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change app language programmatically in Android
Resources res = context.getResources(); // Change locale settings in the app. DisplayMetrics dm = res.getDisplayMetrics(); android.content.res ...
Read more >
How to change the language on Android at runtime and don't ...
After the language change, activity titles are not translated ... We create a special Context which owns a new localized Resources instance.
Read more >
Localize your app - Android Developers
When users run your app, the Android system selects which resources to load, based upon the device's locale. To create resources, you place ......
Read more >
The All-In-One Guide for Changing App Locale Dynamically in ...
Changing in-App locale is not straight forward in Android as there is no native ... So, we will get the localized string even...
Read more >
Globalization and localization in ASP.NET Core
You develop your app with your default language and prepare it for the localization step without first creating a default resource file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found