Karamunting.Android.Metalurgus.LocaleText 0.0.1.1

LocaleText

Android library to easy change current locale without having to recreate the activity or restart the app

Install-Package Karamunting.Android.Metalurgus.LocaleText -Version 0.0.1.1
dotnet add package Karamunting.Android.Metalurgus.LocaleText --version 0.0.1.1
<PackageReference Include="Karamunting.Android.Metalurgus.LocaleText" Version="0.0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Karamunting.Android.Metalurgus.LocaleText --version 0.0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Simple Usage

Please refer to original doc https://github.com/metalurgus/LocaleText for more information.

// Rofiq Setiawan

using Android.App;
using Android.OS;
using Android.Support.V7.App;
using Metalurgus.Github.Com.Lib.Base.Base;
using Metalurgus.Github.Com.Lib.Base.Views;
using Locale = Java.Util.Locale;
using R = LocaleTextDemo.Resource;

namespace LocaleTextDemo
{
    [Activity(Label = "@string/app_name", MainLauncher = true, Theme = "@style/AppTheme.NoActionBar")]
    public sealed class MainActivity : AppCompatActivity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(R.Layout.activity_main);

            // RU button
            FindViewById<LocaleTextButton>(R.Id.rus).Click += delegate
            {
                LocaleText.SetLocale(new Locale("ru", "RU"), this);
            };

            // EN button
            FindViewById<LocaleTextButton>(R.Id.eng).Click += delegate
            {
                LocaleText.SetLocale(new Locale("en", "US"), this);
            };

            // Custom Listener TextView
            FindViewById<LocaleTextTextView>(R.Id.custom_listener).SetOnLocaleChangeListener(
                new OnLocaleChangeListener(
                    (locale, localeResId, context, listenable) =>
                    {
                        switch (locale.ISO3Language.ToLower())
                        {
                            case "rus":
                                listenable.SetText(context.Resources.GetString(R.String.custom_text));
                                break;

                            case "eng":
                                listenable.SetText(context.Resources.GetString(R.String.custom_text));
                                break;
                        }
                    }
                )
            );
        }
    }
}

Simple Usage

Please refer to original doc https://github.com/metalurgus/LocaleText for more information.

// Rofiq Setiawan

using Android.App;
using Android.OS;
using Android.Support.V7.App;
using Metalurgus.Github.Com.Lib.Base.Base;
using Metalurgus.Github.Com.Lib.Base.Views;
using Locale = Java.Util.Locale;
using R = LocaleTextDemo.Resource;

namespace LocaleTextDemo
{
    [Activity(Label = "@string/app_name", MainLauncher = true, Theme = "@style/AppTheme.NoActionBar")]
    public sealed class MainActivity : AppCompatActivity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(R.Layout.activity_main);

            // RU button
            FindViewById<LocaleTextButton>(R.Id.rus).Click += delegate
            {
                LocaleText.SetLocale(new Locale("ru", "RU"), this);
            };

            // EN button
            FindViewById<LocaleTextButton>(R.Id.eng).Click += delegate
            {
                LocaleText.SetLocale(new Locale("en", "US"), this);
            };

            // Custom Listener TextView
            FindViewById<LocaleTextTextView>(R.Id.custom_listener).SetOnLocaleChangeListener(
                new OnLocaleChangeListener(
                    (locale, localeResId, context, listenable) =>
                    {
                        switch (locale.ISO3Language.ToLower())
                        {
                            case "rus":
                                listenable.SetText(context.Resources.GetString(R.String.custom_text));
                                break;

                            case "eng":
                                listenable.SetText(context.Resources.GetString(R.String.custom_text));
                                break;
                        }
                    }
                )
            );
        }
    }
}

Version History

Version Downloads Last updated
0.0.1.1 325 4/27/2018