Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

thudugala/Plugin.Localization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using Xamarin.Forms String Localization, What this plugging was trying to achieve can be achieved now.

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/localization/text?pivots=windows

icon

Plugin.Localization

Build cross-platform multilingual applications with Xamarin.Forms using the built-in .NET localization framework.

Setup

Platform Support

Platform Supported Version Notes
Xamarin.iOS Yes iOS 7+
Xamarin.Android Yes API 16+ Project should target Android framework 8.1+

Usage

Getting Started

Add Resource file

Add Resource File

Add Resource per language.

Resource Per Language

Localizing XAML

Set the Resource to Public

Resource To Public

How to use in XAML

Localizing XAML

Code Change.

Android and IOS projects automatically sets the resource's culture correctly to the CultureInfo.InstalledUICulture. Also set the Culture in all the resource's in all the assemblies. Only need to reference this package if that is not the case.

using System;
using System.Globalization;
using Plugin.Localization;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

//translateManager only set Culture in resource's, only when Attribute is set.
[assembly: ResxLocalize]

namespace Local.Sample
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
            
            var localizeHelper = DependencyService.Resolve<ILocalizeHelper>();
            var languageConvertor = new LanguageConvertor();
            var translateManager = new TranslateManager(localizeHelper, languageConvertor);

            // Set Culture in all the resource's in all the assemblies that has ResxLocalize Attribute.
            translateManager.SetCulture();

            MainPage = new MainPage();
        }

        protected override void OnStart()
        {
            
        }

        protected override void OnSleep()
        {
            // Handle when your app sleeps
        }

        protected override void OnResume()
        {
            // Handle when your app resumes
        }
    }
}

Limitations

Only support iOS and Android for the moment.

Contributing

Contributions are welcome. Feel free to file issues and pull requests on the repo and they'll be reviewed as time permits.

Icon

Thank you for the Icon by Juliia Osadcha (https://www.iconfinder.com/Juliia_Os)