Is it possible to use localization from web service?

MakMak INMember ✭✭

Is it possible to get language resource files from web service and use them in apps at run time based on local?
The benefit is that strings can be changed anytime on web and reflect in apps without the need of publishing the app again.

Or even is it possible to use resource files from storage without adding them in assembly?

If anybody has tried such a solution, I request the suggestions.

Best Answer

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    You could get the user's language following this thread: https://stackoverflow.com/a/27231721/8354952.
    Then submit a request to your web service with this language parameter via rest api. You could also include other parameters such as where to display this string so that you will get the corresponding string from your service.
    But I really don't recommend you to do that. because when the user's network is not good enough to access these strings, the interface will be messed up.
    Sometimes, publish a new version is necessary. It could tell users you are attempting to update your projects recently and your app is active.
    Try to use this feature to implement the localization: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/localization/

  • MakMak INMember ✭✭

    @LandLu , Thank you for the response.
    I have service ready for getting language resources in json/xml format. And I can easily get it from app using rest. The problem is how to inject it instead of resx files key/values. Is it possible to customize the existing localization functionality in xamarin forms? Is it possible to use key/value from external json/xml file which is not part of the assembly?

    I am very much agree that due to network issues it can create problems, but you can understand developers can't take all the decisions. :smile: And I think once we get it, it can be stored somewhere and used if service is not available next time.

Sign In or Register to comment.