Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Android
TodoShared
iOS
README.md
TodoLocalizedShared.sln

README.md

TodoLocalized (Xamarin.Forms Shared Project)

WARNING: requires a hack. not recommended unless the consequences are understood.

A complete application that demonstrates the localization concepts from this developer portal page, and its sample code.

This sample uses a Shared Project (rather than .NET Standard Library) for the common Xamarin.Forms code.

Making this work is a hack - you can no longer rely on the designer.cs file being auto-generated for the default resources, which breaks the strongly-typed AppResources. mechanism of accessing translated strings.

The differences between this Shared Project sample and the .NET Standard Library sample are:

  • The default namespace in each platform project was changed:

    • before: Todo.iOS, Todo.Android, Todo.UWP
    • after: TodoLocalized (all the same)

    normalizing the namespaces to a single value helps with the resource loading.

  • The Resx folder with RESX files was manually added to the Shared Project (from the existing .NET Standard Library sample). If you add a new Resource File from the IDE, you'll get an error message "Error: ResXFileCodeGenerator can only be used with .NET projects." For language-specific RESX files, simple click on the added file and in the Properties pad remove the "Custom Tool: ResXFileCodeGenerator" setting (leave it blank), and ensure the build action is set to Embedded Resource.

  • For the default resources AppResources.resx file - which normally would have the AppResources.designer.cs file auto-generated - you must manually keep the C# properties synchronized with whatever string elements you add to the resources XML��. This is going to be incredibly tedious and error prone, so using RESX localiztion with Shared Projects is not typically recommended unless you understand these limitations!

WARNING: the Universal Windows Platform project has not yet been completed.

You can’t perform that action at this time.