Karamunting.Android.Metalurgus.LocaleText 0.0.1.1

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.
#r "nuget: Karamunting.Android.Metalurgus.LocaleText, 0.0.1.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Karamunting.Android.Metalurgus.LocaleText as a Cake Addin
#addin nuget:?package=Karamunting.Android.Metalurgus.LocaleText&version=0.0.1.1

// Install Karamunting.Android.Metalurgus.LocaleText as a Cake Tool
#tool nuget:?package=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;
                        }
                    }
                )
            );
        }
    }
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.0.1.1 659 4/27/2018