How to implement localization in the latest 2017 VS without using PCL?

Hello

In previous projects I used the resx/PCL approach to implement localization in my Xamarin.forms solutions. As of the update to VS, this has been deemed deprecated and the information I find instruct me to "use the .NET standard".

When trying to implement a resx language file, the strongly typed connection is no longer available and the ResXFileCodeGenerator tool for converting resx to designer.cs "does not exist in a non .NET environment".

VS still allows me to add a PCL project to my Xamarin.forms, but since it has officially been depricated, I do not want to use that.

The article at Xamarin describing how to do it (https://developer.xamarin.com/guides/xamarin-forms/advanced/localization/), has yet to be updated to use .NET standard, where the resx file is automatically converted into a designer.cs file, that used to enable the strongly typed use of strings.

Are there anyone out there that could help me create a way to use localization in the latest VS 2017 (for Mac) without using a PCL nor individual implementation of localization in separate platforms (Andorid/iOS)?

Answers

  • BananaTieBananaTie DKMember ✭✭

    Hi @DirkWilhelm

    Thank you for the answer - that seems to solve my issue!

    For some reason the sample even works on Visual Studio for Mac, including the strongly typed ressources. It seems to have something to do with the 'PublicResXFileCodeGenerator' instead of the old 'ResXFileCodeGenerator'.

  • ZoliZoli NLMember ✭✭✭

    Hi guys, I want to keep the auto-generated AppResources.MY_STRING_ID usage with netstandard2.0, any idea how to do that? I don't like this overcomplicated multilingual-app-toolkit above.
    See my post.

  • BananaTieBananaTie DKMember ✭✭

    Hi @Zoli
    I solved it by creating and adding a .NET standard 2.0 DLL to my project and leave the language related resources in there and then reference the DLL from my Android/iOS main projects.
    Only thing I needed to add was the 'PublicResXFileCodeGenerator' option on the language file itself and it would generate the needed link to the language in question.
    This solution worked for me in both Visual Studio 2017 for Windows and for Mac.

    It is the simplest way I have found - and does not use the multilingual app toolkit.

  • ZoliZoli NLMember ✭✭✭
    edited March 2018

    Thanks, not bad.

    It seems I also found a workaround with netstandard20:
    1. add new strings the resx files in VS editor.
    2. then manually edit/add the new string properties to AppResources.Designer.cs (only to this, all the other AppResources.$LANG$.Designer.cs files are empty!). Very simple syntax, just see how it was done by prev PCL Xamarin.
    3. Done

    Your one maybe better though. But both works.

  • AgredoAgredo USMember ✭✭

    @Zoli said:
    Thanks, not bad.

    It seems I also found a workaround with netstandard20:
    1. add new strings the resx files in VS editor.
    2. then manually edit/add the new string properties to AppResources.Designer.cs (only to this, all the other AppResources.$LANG$.Designer.cs files are empty!). Very simple syntax, just see how it was done by prev PCL Xamarin.
    3. Done

    Your one maybe better though. But both works.

    I created a new project. I Installed the Multilingual App Toolkit. But now? Thanks for your help.

  • ZoliZoli NLMember ✭✭✭

    I created a new project. I Installed the Multilingual App Toolkit. But now? Thanks for your help.

    Did you read the documentation of Multilingual App Toolkit how to use?
    I don't use any external tools for languages.

  • AgredoAgredo USMember ✭✭
    edited May 2018

    Yes but i dont have the Helpers Folder. I dont really know how it wold be if this works correctly. I thought maybe your solution could help me.

    I created a .Net Standard Xamarin.Forms Project.

  • AdrnHAdrnH USMember ✭✭
    edited October 2018

    @Zoli said:
    Thanks, not bad.

    It seems I also found a workaround with netstandard20:
    1. add new strings the resx files in VS editor.
    2. then manually edit/add the new string properties to AppResources.Designer.cs (only to this, all the other AppResources.$LANG$.Designer.cs files are empty!). Very simple syntax, just see how it was done by prev PCL Xamarin.
    3. Done

    Your one maybe better though. But both works.

    I solved this by adding a new .resx file to my Resource folder and copy the old .xml content of the old .resx file into the new .resx file. Now I have Resources which update their Designer automatically again.

  • BillFultonBillFulton AUMember ✭✭

    @AdrnH Worked for me.

Sign In or Register to comment.