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.

How to switch back to system default locales?

See original GitHub issue

Hi,

I’m considering to use this library in my projects but I didn’t find way how to switch back to original system settings? What value should be set to updateLocale method if I don’t want to override system settings anymore?

Rationale: users may try this feature but find that localization to any language from the list does not fit them. So they want to return back to original state before they tried the feature. But I don’t know how to implement that.

Thanks for your help Tom

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
hiddeneyes02commented, Oct 1, 2020

You can pass the locale below to achieve what you want:

ConfigurationCompat.getLocales(Resources.getSystem().configuration)[0]

1reaction
gunhansancarcommented, Sep 25, 2020

Hi @thubalek,

It is pretty rare scenario but it is easy to handle. Because if you give the user option to change language on the fly you present them let say x amount of languages. When they select a language they can always select their native language from the list again.

So if you want to mark the system language for the user for instance, you can do that easily. When the app first loads, the Locale is filled statically by the system default. So Locale.getDefault() returns the system language at the beginning. The idea is you save this information somewhere and use it later on. If this is useful I can directly return it from the library itself actually.

In your custom Application class, override the attachBaseContext method and before calling the super save the systemLocale.

    override fun attachBaseContext(base: Context) {
        val systemLocale = Locale.getDefault()
        super.attachBaseContext(localeAppDelegate.attachBaseContext(base))
    }

After that point though, Locale is overridden by the library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change system locale in Windows 10 - The Language for
Click the Administrative tab, and then, under Language for non-Unicode programs, click Change system locale. Image If you're prompted for an ...
Read more >
2 Ways to Change System Locale in Windows 10
Select the desired language from the Current system locale drop-down list, and click OK. Restart your computer for the changes to take effect....
Read more >
How to Change System Locale on Windows 10 - YouTube
How to Change System Locale on Windows 10. How to Change the System Locale on a Windows Computer.Issues addressed in this tutorial: change...
Read more >
How to Change or Set System Locales in Linux - Tecmint
If you want to change or set system local, use the update-locale program. The LANG variable allows you to set the locale for...
Read more >
Change System Locale in Windows 10 - Winaero
The option that specifies the default language to use for non-Unicode programs is called System Locale. The system locale defines the bitmap ...
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