Application resources and localization sample

This sample shows how to use application resources to separate localizable content from app code.

 
 
 
 
 
(11)
40,731 times
Add to favorites
4/2/2014
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • String Globalization and UserControl
    1 Posts | Last post September 04, 2014
    • Would it be possible to add an example in this that shows how to globalize strings in a UserControl?  I'm trying to create a user control that has "OK" and "Cancel" buttons but I cannot find any way to globalize the text for those buttons in my user control xaml code.
  • Facing problem in Phycial device .
    4 Posts | Last post June 04, 2014
    • I am using localization in same way . its working while doing development but when i am trying to install the package in my device , the application is not reflecting the localization . even i installed your project package in my device this application also behaving same way (working in Desktop and not working in Device ). do i need to put any other effort to make sure that this application change the content in my device also . please let me if you have any suggestion . 
    • I'm facing the same problem. Working in development but not working from the package. Have anyone solved this issue?
    • Hi Shivam,
      I've solved it! The problem is in the package creation. You should change the bundle option preselected from always to never. 
      Regards,
      Pau
    • Hi Pau , 
      I struggled a lot for the issue i found your answer useful a big Thanks to you . :)
      Regards 
      Shivam 
  • How to access Key.Property resource with C#
    2 Posts | Last post July 10, 2013
    • Hi.
      
      I have localized my app design but now I want to access those localization with C#.
      I have keys like MyAppName.Header or ErrorMessage.Text and I can't access this message with C#.
      
      var resourceLoader = new ResourceLoader();
      string error = resourceLoader.GetString("ErrorMessage.Text");
      
      I know I can just change it to ErrorMessage but then I can't localize UI without C# code or I need to duplicate everything. I want to localize some stuff in ViewModel and there are some stuff hard-coded in design.
    • When you use a name in the .resw file like ErrorMessage.Text, the first part because a subtree node in the resource map hierarchy. When you access resources programmatically, subtree nodes are delimited using a backslash (the reference is actually a URI string). You should call GetString using "ErrorMessage\Text". 
      
      If you needed to access a number of resources under the ErrorMessage subtree, then you can also get a ResourceLoader instance that's scoped to that subtree:
      
      var errorResourceLoader = ResourceLoader.GetForCurrentView("ErrorMessage");
      
      Note: the constructor is now deprecated since it is not view aware and can lead to bugs in multimon scenarios. You can use the static method GetForCurrentView() on a UI thread.
  • Scenario 6 doesn't show what it should
    2 Posts | Last post July 10, 2013
    • Because the messages for the app resources and the class library resources both say "Hello World", I went into the resources.resw for scenario 6, located in the AppResourceClassLibrary project, and changed its value to "Hello World from the Class Library" and then re-built/ran the app. Now BOTH the "retrieved from the app" and the "retrieved from the class library" messages say the same thing: "Hello World from the Class Library". How should I fix this?
    • The .resw files used by the library are -- in the CPP version --
      \AppResourceClassLibrary\Resources.lang-en.resw
      \AppResourceClassLibrary\Resources.lang-fr.resw
      \AppResourceClassLibrary\Resources.lang-ja.resw
      
      Is that what you changed?
  • Ambiguous Reference
    2 Posts | Last post March 07, 2013
    • Why i am getting this error message:
      ResourceLoader.GetString("MyRessource"); <- resource exsits for DE and EN.
      
      i can build my Solution but thats very ugly...
      
      
      Thanks, Tim
    • The error Message is: Ambiguous: "MyRessource", "MyRessource" match
  • To localize aria-label
    3 Posts | Last post August 01, 2012
    • Does anyone know how to localize the "aria-label", or the label of appBar in JS-based Metro app?
      I think it corresponds to scenario 9 of the Js sample,
        <button style="display: none" data-win-res="{attributes: { 'aria-label' : 'scenario9AriaLabel' }}"> 
      
      However, per my test, this could not work on consumer preview, build 8250.
      
      Thanks.
      
      
      
    • Hi Rudy, 
      Your syntax appears to be correct at first glance. Did you use the DOM Explorer to inspect the element and ensure the attribute was not set? Was the attribute not set all or just incorrectly? What are your user language preferences (Control Panel > Clock, Language, and Region > Language)? Did you modify the sample at all? Was WinJS.Resources.processAll() called?
      
      Thanks.
      
      Rylan
    • http://channel9.msdn.com/Blogs/How-Do-I/How-Do-I-Implement-App-Bars-in-a-Windows-8-Metro-Style-Application-Part3
  • Hi Tim, thanks for your interest
    2 Posts | Last post October 28, 2011
    • 
      Hi Tim, 
      
      (Topic for a string of a resource from an assembly WinRT - Window8 System) 
      
      thank you for your interest in the question 
      
      my problem is how to get a string resource from a container of resources defined in an assembly.
       
      I would simply call the equivalent method ResourceLoader.GetString string s = ("MyStringAlias") in an assembly.
       
      This method works well in an executable. 
      
      What I want is to get the same result, which in addition was automatically generated with the old method of management of string resources.
       
      like: 
      
       internal static global:: ResourceManager {System.Resources.ResourceManager 
                  get { 
                      if (Object.ReferenceEquals (resourceMan, null)) { 
                          global:: System.Resources.ResourceManager temp = new global:: System.Resources.ResourceManager ("[namespace]. ResourceStrings, typeof (MyAssemby));
                           resourceMan = temp; 
                      } 
                      resourceMan return; 
                  } 
              } 
      
         public static string MyStringEveryWhere 
              { 
                  get 
                  { 
                      ResourceLoader.GetString return ("MyStringEveryWhere"); 
                  } 
              } 
      
      
      I constaste is that "ResourceLoader" sees only the channels defined in its own resources of the executable.
       
      
      Regards Eric Chauvet 
      
      
    • eric -- can you ping me at timheuer at microsoft and i can work with you on this.  this particular QA form on this site isn't helpful to get a solution to you fast (code not coming across clear)
  • how do i use ResourceLoader from an Assembly
    2 Posts | Last post September 30, 2011
    • I can see resources from exe not from dll
    • Hi Eric, can you provide more details?  What do you mean you cannot see resources from DLL?