×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    113

    Localization using a PCL

    Has anyone tried putting their app localization resource files into a portable class library? I am using the MVVM pattern and have created a PCL to store my models and viewmodels. I'm doing this so that I can target windows 8 afterwards. I have moved the AppResource.resx file into the PCL and reference it using this class:

    Code:
    public class LocalizedStrings
        {
            private static AppResources _localizedResources = new AppResources();
    
            public AppResources LocalizedResources { get { return _localizedResources; } }
        }
    This works fine. In fact, I just published the app this way. However, I'm having huge problems trying to localize the app. The Multilingual App Toolkit doesn't run in a PCL, so I moved the AppResource file back to the WP8 project. Then, I generated two other languages (fr and es) and did a machine translation (which, BTW, is really very good... at least I can tell that the French translation is pretty amazing). I moved the main AppResource.resx file back to the PCL and also moved the generated xlf files.

    However, no matter what I try to do, English is always displayed. I have the emulator language set to French. The numbers are being displayed properly (with a comma instead of period for decimals) but none of my translated strings are being shown.

    I don't exactly understand the point of the following line in the App.xaml.cs file:
    Code:
    RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage);
    but it is always returning en-US, even when the emulator is as French as I can make it.

    Both, the project properties and the AppManifest have the appropriate languages checked.

    Does anyone know what I am doing wrong?

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Localization using a PCL

    Well I don't actually know what's the point of manually setting the Language of the RootFrame (I don't have that line in my code)
    but you can always check the current language and culture using Thread.CurrentThread.CurrentCulture and then get the language sting using TwoLetterISOLanguageName

    also perhaps you should check if you set the supported languages in the Languages tag in the WMAppManifest and also make sure you name your french AppResource AppResources.fr
    Heard of DVLUP? Join here

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    34

    Re: Localization using a PCL

    Have you checked if the localized assemblies are being deployed?

  4. #4
    Nokia Developer Champion
    Join Date
    Dec 2012
    Posts
    45

    Re: Localization using a PCL

    Maybe the PCL recognize the AppResource.resx but not the xlf files.... PCL has limitation... Did you tried to have two resx files, one for en and another for fr, did worked?
    __________________________________________________

    @saramgsilva
    Microsoft MVP - Visual C#
    Nokia Developer Champion

  5. #5
    Regular Contributor
    Join Date
    Aug 2012
    Location
    Rhine Valley
    Posts
    93

    Re: Localization using a PCL

    I'm using "Add as Link" for the resource files. This poses no problems with localization. See http://developer.nokia.com/community..._Windows_Phone.
    - <a href="http://www.dvlup.com/influencer/invite">Visit DVLUP and earn rewards</a>

  6. #6
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    113

    Re: Localization using a PCL

    Quote Originally Posted by influencer View Post
    I'm using "Add as Link" for the resource files. This poses no problems with localization. See http://developer.nokia.com/community..._Windows_Phone.
    This works perfectly!! Thank you!

    Just to be clear for anyone else:

    1. I created my english-language resource file in the WP8 project.
    2. I ran the Multilingual App Toolkit on the WP8 project and created my various translations.
    3. I copied the resx files that are generated, NOT the xlf files, to the PCL using the Add->Existing Item... -> Open as Link (part of the Open button)

    This seems to work well for my WP8 app. I haven't tested it on a Win8 app, but I have high hopes.

  7. #7
    Regular Contributor
    Join Date
    Aug 2012
    Location
    Rhine Valley
    Posts
    93

    Re: Localization using a PCL

    I never used the Multilingual App Toolkit and instead did all translations in renamed copies of the original resx manually. The resx files are all that is needed in the other projects, so you're right.

    I don't know if you intend to translate the app title and its description, too. In this case the C++ resource-only DLLs you have to create in most cases can be shared, too - for example, if you have a WP7 and a WP8 version that share the same app name. See http://developer.nokia.com/community...g_the_app_name.
    - <a href="http://www.dvlup.com/influencer/invite">Visit DVLUP and earn rewards</a>

  8. #8
    Registered User
    Join Date
    Jul 2014
    Posts
    1

    Re: Localization using a PCL

    https://github.com/xhackers/ResxForms/ has a code sample where Resource files are hosted in PCL and accessed from WP8, iOS and Android.

    Hope that helps.

Similar Threads

  1. localization on SMS
    By abelk in forum Mobile Java Networking & Messaging & Security
    Replies: 15
    Last Post: 2010-02-04, 11:50
  2. Localization
    By Arunesh in forum Mobile Java General
    Replies: 9
    Last Post: 2009-10-21, 11:26
  3. about localization
    By ceehira in forum Symbian
    Replies: 2
    Last Post: 2005-08-05, 07:29
  4. Localization
    By Nokia_Archive in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2002-05-15, 02:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×