Answered by:
Windows store app Resource localization issue in windows 8.1 with new API, Always picking the default English resource.

Question
-
I am developing a Windows store app using VS2013 for Windows 8.1.
ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse("ClassLibrary/Resources");
string resourceValue = resourceLoader.GetString("string1");My machine locale is set to French (fr-FR) and my project contains 3 resources file(Resources.resw) one for English,French and Japanese each. default language set in the manifest file is English. while running the above piece of code , GetString("string1") returning the english string from the english resources. I am not getting any clue why it is happening instead of French it is showing English.
When i put above code in the startup project then it is working as expected.
ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse("Resources");
string resourceValue = resourceLoader.GetString("string1");please suggest some solution.
Thanks.
Monday, January 20, 2014 10:45 AM
Answers
-
Hello rajeev!
I was just writing a post for that but it is not yet complete. However, I want to write a snippet here for you so that you can play according to your needs.
public static string GetResource(string stringResource) { var context = ResourceContext.GetForCurrentView(); var lang = new List<string>(); lang.Add(VPSettings.Language); context.Languages = lang; var resourceStringMap = ResourceManager.Current.MainResourceMap.GetSubtree("Resources"); return resourceStringMap.GetValue(stringResource, context).ValueAsString; }
You can replace VPSettings.Language with your desired culture name (e.g. en-US or ar-AE)
Regards
Arafat
- Marked as answer by rajeev.ipass Wednesday, January 22, 2014 6:31 AM
Tuesday, January 21, 2014 7:47 PM -
Thanks Arafat, It is working for me.
I am curious ,What could be the issue in my sample posted at below link.
https://skydrive.live.com/redir?resid=87620D2F2C8BC01F%21236
- Marked as answer by rajeev.ipass Wednesday, February 19, 2014 9:10 AM
Wednesday, January 22, 2014 5:29 AM
All replies
-
Hi,
Would you mind sharing your sample in the SkyDrive? So that we can test it to see why the problem occur. And you can also see the link below:
Hope this can help you!
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.Tuesday, January 21, 2014 7:59 AM -
Here is the sample link:
https://skydrive.live.com/redir?resid=87620D2F2C8BC01F%21236
the sample build on VS2013.
Tuesday, January 21, 2014 9:09 AM -
Hello rajeev!
I was just writing a post for that but it is not yet complete. However, I want to write a snippet here for you so that you can play according to your needs.
public static string GetResource(string stringResource) { var context = ResourceContext.GetForCurrentView(); var lang = new List<string>(); lang.Add(VPSettings.Language); context.Languages = lang; var resourceStringMap = ResourceManager.Current.MainResourceMap.GetSubtree("Resources"); return resourceStringMap.GetValue(stringResource, context).ValueAsString; }
You can replace VPSettings.Language with your desired culture name (e.g. en-US or ar-AE)
Regards
Arafat
- Marked as answer by rajeev.ipass Wednesday, January 22, 2014 6:31 AM
Tuesday, January 21, 2014 7:47 PM -
Thanks Arafat, It is working for me.
I am curious ,What could be the issue in my sample posted at below link.
https://skydrive.live.com/redir?resid=87620D2F2C8BC01F%21236
- Marked as answer by rajeev.ipass Wednesday, February 19, 2014 9:10 AM
Wednesday, January 22, 2014 5:29 AM -
I will try to give your sample a shot. If the above answers your question then you can mark it as an answer to close this thread.
Thanks
Arafat
Wednesday, January 22, 2014 6:13 AM