dease
dease

Reputation: 3076

Sharing string resources between platforms in PCL project

I am creating Xamarin multi-platform mobile project where I want to use PCL shared project to share some parts of the code.

I also want to share one strings files between the platforms, as they will be the same for each of the platforms.

I've created new .resx file in my PCL project, but I dont know how can I use its values in my Android/iOS projects. Any suggestions?

Content of AppResources.resx in PCL project:

<?xml version="1.0" encoding="utf-8"?>
<root>
    <resheader name="resmimetype">
        <value>text/microsoft-resx</value>
    </resheader>
    <resheader name="version">
        <value>2.0</value>
    </resheader>
    <resheader name="reader">
        <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    <resheader name="writer">
        <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    <data name="ConnectButton" xml:space="preserve">
        <value>Connect</value>
    </data>
    <data name="IpAddress" xml:space="preserve">
        <value>IP Address</value>
    </data>
</root>

Upvotes: 1

Views: 1698

Answers (1)

Cheesebaron
Cheesebaron

Reputation: 24470

You should be able to just write:

var ipAddress = AppResources.IpAddress;

or

var connectButton = AppResources.ConnectButton;

You can find more information in the documentation: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/localization/

Upvotes: 2

Related Questions