1
votes

I am working on porting an iOS App to WP8. The iOS app is localized to 5 different languages. The localized strings are stored in different files. For example "app.strings" hold all strings unique for the app and "common.strings" hold strings that are used in other apps as well. Of course there are 5 versions of each .strings file (app.de.strings, app.en.strings, ....).

In the iOS code I can simple refere to "String_ID_123" and the system will automatically search for that string in all .strings files and display the correct value, no matter if this string can be found in app.strings, common.strings or elsewhere. Is this possible on WP8 as well?

VS automatically created two files to support localization:

  • AppResources.resx which holds the actual strings (with AppRessources.Designer.cs as code behind)
  • LocalizedStrings.cs which is a helper class to support binding

Of course I could add additional .resx files to the project and use them create the same structure as in the iOS project. But then I would have to add additional versions of LocalizedStrings.cs (e.g. LocalizedStrings_Common.cs) which refere to the correct .resx as well. Then I would have to explicitly use the correct Souce in XAML.

I would have to know where String_ID_123 is defines. Is there any way to let XAML/C# do that automatically?

1

1 Answers

1
votes

I'm afraid VS isn't gonna help you with this. First, you cannot address String_ID_123 without specifying the resource file it resides in. Second, when you add additional resource files (e.g. CommonResources.resx) VS will not modify LocalizedStrings for you. You will have to do that yourself.

   public class LocalizedStrings
    {
        private static AppResources _localizedResources = new AppResources();
        private static CommonResources _locallizedCommonResources = new CommonResources();

        public AppResources LocalizedResources { get { return _localizedResources; } }
        public CommonResources LocalizedCommonResources { get { return _locallizedCommonResources; } }

And third, when you add new languages to your project, VS will generate AppResources.fr.resx for you but will not generate CommonResources.fr.resx. You'll have to add a copy your self.