I am taking the inspiration from Localization in WP8.x.
Add Resx resources in a Resources folder in PCL project.
Create a LocalizedResources class in PCL Project:
`namespace MyApp
{
///
/// Provides access to string resources.
///
public class LocalizedStrings
{
private static Resources.AppResources _localizedResources = new Resources.AppResources();public Resources.AppResources LocalizedResources { get { return _localizedResources; } } }
}`
Create a global LocalizedStrings static resource in App.xaml
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyApp.App"> <Application.Resources> <ResourceDictionary> <local:LocalizedStrings xmlns:local="clr-namespace:MyApp" x:Key="LocalizedStrings"/> </ResourceDictionary> </Application.Resources> </Application>
In the main content page xaml bind to the localized string:
<?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyApp.MainPage"> <Label Text="{Binding Source={StaticResource LocalizedStrings}, Path=LocalizedResources.WelcomeMessage}" VerticalOptions="Center" HorizontalOptions="Center" /> </ContentPage>
Running the app shows no message in the label. My understanding was that in Xamarin.Forms binding, both Source and Path with nested properties are supported. Am I doing something wrong here?