You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RestringResources relies on a deprecated constructor. The description about the deprecation is:
Resources should not be constructed by apps. See Context.createConfigurationContext(Configuration).
It appears that replacing the Resources instance with custom one is not something Android intends to support. Any ideas about what to do if they do remove that constructor? I see another public constructor, but its documentation is marked with @hide, for which I would expect an implementation that used it to be equally brittle.
@B3nedikt I think you should add an issues list to your fork. I would have posted this question to there, had it existed. I could understand wanting to have the issues for Restring be in a single place, but having an issues list might give others an idea of how much other people are using your fork.
The text was updated successfully, but these errors were encountered:
That is correct, custom Resources are not supported by android, that's kind of the reason why the getString() methods on Context are final.
I think there are two intended ways to deal with this:
Create a copy of the Context and pass this around using DI. Works well for stuff like changing the language of the app, but you can´t actually replace the resources like restring does.
Provide a completely new localization system specific for your app, and use it everywhere. This is quite the effort especially for legacy apps. There is a lot to consider like switching language, redrawing etc.
At the moment the way restring does it is the simplest way, I am looking to abstract some stuff away here and make option 2 above easier to implement with a new lib, but I think for legacy apps you don´t really have a choice. Replacing all those getString() calls can be a pain, if they are not properly abstracted away ;)
You could have a look at https://github.com/JcMinarro/Philology.
It uses the same approach as @hamidness original restring, but it is more stable. I think my fork is the way to go if you need more features like applying changes without restarting the activity and changing your apps language, Philology is more lightweight though.
I added an issue list to my fork, I don´t think a lot of people are using it though. I only use it in a single project myself in production :)
RestringResources
relies on a deprecated constructor. The description about the deprecation is:It appears that replacing the
Resources
instance with custom one is not something Android intends to support. Any ideas about what to do if they do remove that constructor? I see another public constructor, but its documentation is marked with@hide
, for which I would expect an implementation that used it to be equally brittle.@B3nedikt I think you should add an issues list to your fork. I would have posted this question to there, had it existed. I could understand wanting to have the issues for Restring be in a single place, but having an issues list might give others an idea of how much other people are using your fork.
The text was updated successfully, but these errors were encountered: