locked
app localization: string files

    Question

  • Hello guys.

    I've started poking around globalization and I've got  a simple question about string localization. After reading the quickstart, I'm under the impression that localized strings should be defined in files named resources.resjson which should be put inside folders which defines their cultures (ex.: pt-PT, etc). 

    Now, the questions:

    1. I'm under the impression that the name used is  important. In other words, the resource file must be named resources.resjson. Am I wrong? Btw, if this is true, why do the sample has another localized file called errors.resjson?

    2. The docs say that resource files should be kept at resW or resjson files. Looking at the sample, I can only find resjson and json files. What are these resW files? Are these used from C#?

    3. I'm still not sure on what happens when windows can't find the correct localized file. any comments?

    4. Ok, I've run some more tests and here's another question. I've got the following languages installed in this order: PT (keyboard only since there's no display language package yet), english and french. I've tried rearranging them so that french comes first. The question: I can't build my app if I don't specify resource files for the english locale. It keeps saying that no resources were found for default language. But doesn't  putting french as the first item in the list makes french the default language for the system??? 

    thanks.


    Luis Abreu



    Sunday, May 27, 2012 2:04 PM

Answers

  • 1. They're used for loading resources from the web context

    2. the docs are wrong and I still haven't found any usage of the,

    3. it will keep going on the list of installed languages until it finds a resource localized for that language

    4. not sure about this.


    Luis Abreu

    Monday, May 28, 2012 1:22 PM
  • 4. ok, got it. You need to pass resources for the default project language which is defined in the properties of the project.

    Luis Abreu

    Monday, May 28, 2012 2:05 PM
    1. The name of a resjson (or resw) file defines the scope of any resources it contains.   So the resource declared as "Foo" in "resources.resjson" is actually named "resources/Foo" while the same string in "errors.resjson" is actually named "errors/resources.foo."

      Resources.processAll() and the default ResourceLoader() both look in the "resources" scope for strings, so you have to be careful when using other scopes.  For example, if you specify a scope when creating a resource loader then the ResourceLoader you get back will look in "errors" instead of "resources". 
    2. ResW is an XML format used primarily XAML apps.  It's, um, eerily reminiscent of the existing .NET ResX format so it's very familiar to XAML developers.   That said, it is actually possible to use either source format - you just have to set the file type correctly in VS.
    3. When the Resource Management System can't find an exact match, it falls back to the next best match or eventually to an ultimate fallback (if one is defined).
    4. You have English set as the default language for your project, but you haven't defined English resources.   That's a warning because it means that some of your resources have no ultimate fallback.  You can go into project properties in VS and change the default language to be something that's actually present in your package.   That's that language that will be used if there's absolutely no intersection between the languages supported by your app and those preferred by the user.
    Wednesday, May 30, 2012 6:34 AM

All replies

  • 1. They're used for loading resources from the web context

    2. the docs are wrong and I still haven't found any usage of the,

    3. it will keep going on the list of installed languages until it finds a resource localized for that language

    4. not sure about this.


    Luis Abreu

    Monday, May 28, 2012 1:22 PM
  • 4. ok, got it. You need to pass resources for the default project language which is defined in the properties of the project.

    Luis Abreu

    Monday, May 28, 2012 2:05 PM
    1. The name of a resjson (or resw) file defines the scope of any resources it contains.   So the resource declared as "Foo" in "resources.resjson" is actually named "resources/Foo" while the same string in "errors.resjson" is actually named "errors/resources.foo."

      Resources.processAll() and the default ResourceLoader() both look in the "resources" scope for strings, so you have to be careful when using other scopes.  For example, if you specify a scope when creating a resource loader then the ResourceLoader you get back will look in "errors" instead of "resources". 
    2. ResW is an XML format used primarily XAML apps.  It's, um, eerily reminiscent of the existing .NET ResX format so it's very familiar to XAML developers.   That said, it is actually possible to use either source format - you just have to set the file type correctly in VS.
    3. When the Resource Management System can't find an exact match, it falls back to the next best match or eventually to an ultimate fallback (if one is defined).
    4. You have English set as the default language for your project, but you haven't defined English resources.   That's a warning because it means that some of your resources have no ultimate fallback.  You can go into project properties in VS and change the default language to be something that's actually present in your package.   That's that language that will be used if there's absolutely no intersection between the languages supported by your app and those preferred by the user.
    Wednesday, May 30, 2012 6:34 AM
  • Thanks Erik,

    Thanks for correcting the answer I gave to 1. that answer is completely wrong. (in fact, that answer was related with another question I've asked here about the use of *.json file in the globalization sample app)


    Luis Abreu

    Wednesday, May 30, 2012 8:37 AM