All Projects → NAXAM → i18n-xamarin-forms

NAXAM / i18n-xamarin-forms

Licence: MIT license
Xamarin Localization Library for Xamarin/Xamarin.Forms

Programming Languages

C#
18002 projects
shell
77523 projects

Projects that are alternatives of or similar to i18n-xamarin-forms

Localize
Localize is a framework writed in swift to localize your projects easier improves i18n, including storyboards and strings.
Stars: ✭ 253 (+1388.24%)
Mutual labels:  localization
i18n-literally
🍦 A simple way to introduce internationalization to your JS
Stars: ✭ 80 (+370.59%)
Mutual labels:  localization
awesome-mobile-robotics
Useful links of different content related to AI, Computer Vision, and Robotics.
Stars: ✭ 243 (+1329.41%)
Mutual labels:  localization
onesync-reader-app
Cross-platform ebook reader built using Xamarin.Forms
Stars: ✭ 33 (+94.12%)
Mutual labels:  xamarin-forms
DotNetGraphQL
A sample demonstrating how to create a GraphQL Backend in .NET and consume it from a .NET mobile app created using Xamarin
Stars: ✭ 78 (+358.82%)
Mutual labels:  xamarin-forms
amagaki
A high-performance TypeScript static website generator for building highly-interactive websites. Localization inbuilt. Flexible URLs. Content managed and templates separated.
Stars: ✭ 33 (+94.12%)
Mutual labels:  localization
Flutter translate
Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.
Stars: ✭ 245 (+1341.18%)
Mutual labels:  localization
pdx-ymltranslator
Paradox Interactive YML Translator
Stars: ✭ 18 (+5.88%)
Mutual labels:  localization
flutter localizations
Flutter Localization
Stars: ✭ 21 (+23.53%)
Mutual labels:  localization
Xamarin
Sample Xamarin projects
Stars: ✭ 33 (+94.12%)
Mutual labels:  xamarin-forms
opensource
Collection of Open Source packages by Otherwise
Stars: ✭ 21 (+23.53%)
Mutual labels:  localization
XamarinForms.VisualDebug
A library and client app to view the visual heirarchy of your Xamarin app pages as an interactive tree diagram at runtime
Stars: ✭ 22 (+29.41%)
Mutual labels:  xamarin-forms
arbify flutter
Flutter package providing Arbify support.
Stars: ✭ 18 (+5.88%)
Mutual labels:  localization
Localization.AspNetCore.TagHelpers
Asp.Net Core Tag Helpers to use when localizing Asp.Net Core application instead of manually injecting IViewLocator
Stars: ✭ 25 (+47.06%)
Mutual labels:  localization
FilePicker
FilePicker for Xamarin.Forms
Stars: ✭ 14 (-17.65%)
Mutual labels:  xamarin-forms
React Native Globalize
Internationalization (i18n) for React Native
Stars: ✭ 246 (+1347.06%)
Mutual labels:  localization
Localizr
Localizr is a Tool that handles and automates the generation of localization files for IOS and Android so there will be only one source of truth for all of your localization strings.
Stars: ✭ 33 (+94.12%)
Mutual labels:  localization
S2DHM
Sparse-to-Dense Hypercolumn Matching for Long-Term Visual Localization (3DV 2019)
Stars: ✭ 64 (+276.47%)
Mutual labels:  localization
TextMood
A Xamarin + IoT + Azure sample that detects the sentiment of incoming text messages, performs sentiment analysis on the text, and changes the color of a Philips Hue lightbulb
Stars: ✭ 52 (+205.88%)
Mutual labels:  xamarin-forms
fluent-web
A web component for using projectfluent.org/
Stars: ✭ 41 (+141.18%)
Mutual labels:  localization

Xamarin Localization Library for Xamarin/Xamarin.Forms

Xamarin has provided very detail documentation about how to do localize your application here. However, Xamarin doesn't provide a read-to-use NUGET package.

This project is to provide to Xamrin Developers a ready-to-use NUGET packaget to localize their Xamarin.Forms application.

Install-Package Naxam.I18n

What we have

The original code of this package is to use along with Prism, or the like framework, so code is devided into very small pieces which we could inject easily via IoC support.

  • ILocalizer: To get/set the display language in our app
  • ILocalizedResourceProvider: To get the localized texts
  • IDependencyGetter: To work with DependencyService. You must register one instance of this to provide ILocalizedResourceProvider so the built-in converters/markup extension to work
  • TranslateExtension: A markup extension to translate a given text using ILocalizedResourceProvider
  • TimeAgoConverter: A converter to translate a DateTime/DateTimeOffset instance into recent time display using ILocalizedResourceProvider

How to use

You could look at the demo code for more details.

Provide a ResourceManager instance for our localized texts. If you use IoC support, you should register there instead.

public static ResourceManager ResManager { 
    get
    {
        return new ResourceManager(typeof(LocalTexts));
    }
}

Create and register an instance of IDepenencyGetter so our converter and extension could work. If you use IoC, you could resolve these things by using IoC container.

public class DepenencyGetter : IDependencyGetter
{
    readonly Dictionary<Type, object> cache;
    public DepenencyGetter()
    {
        ILocalizer localizer = new Localizer();
        cache = new Dictionary<Type, object> {
            {
                typeof(ILocalizer), 
                localizer
            },
            {
                typeof(ILocalizedResourceProvider), 
                new LocalizedResourceProvider(localizer, App.ResManager)
            }
        };
    }

    public T Get<T>()
    {
        return (T)cache[typeof(T)];
    }
}
Xamarin.Forms.DependencyService.Register<IDependencyGetter, DepenencyGetter>();

Get ILocalizer and ILocalizedResourceProvider. If you use IoC, you could use its way of getting dependencies.

var getter = DependencyService.Get<IDependencyGetter>();

var localizer = getter.Get<ILocalizer>();
var localizeResProvider = getter.Get<ILocalizedResourceProvider>();

Change the culture with ILocalizer

localizer.SetLocale(culture);

Get localized text

localizeResProvider.GetText("MainPage_Title");

Use extension and converter

xmlns:i18n="clr-namespace:Naxam.I18n.Forms;assembly=Naxam.I18n.Forms"
xmlns:converters="clr-namespace:Naxam.I18n.Forms.Converters;assembly=Naxam.I18n.Forms"
<ResourceDictionary>
    <converters:TimeAgoConverter x:Key="TimeAgoConverter" />
</ResourceDictionary>
<Label
    Text="{i18n:Translate Page.Title}"
    HorizontalTextAlignment="Center"
    Margin="8"
/>

Provide localized texts for TimeAgoConverter

To use TimeAgoConverter, you need to provide appropriate localized texts for keys as listed below.

<data name="TimeAgo_NA" xml:space="preserve">
    <value>N/A</value>
    <comment>N/A</comment>
</data>
<data name="TimeAgo_LessThan1Minute" xml:space="preserve">
    <value>Just now</value>
    <comment>Less than 1 minute</comment>
</data>
<data name="TimeAgo_LessThan5Minutes" xml:space="preserve">
    <value>Few minutes</value>
    <comment>Less than 5 minutes</comment>
</data>
<data name="TimeAgo_LessThan1Hour" xml:space="preserve">
    <value>{0} minutes</value>
    <comment>Less than 1 hour</comment>
</data>
<data name="TimeAgo_LessThan1Day" xml:space="preserve">
    <value>{0} hrs</value>
    <comment>Less than 1 day</comment>
</data>
<data name="TimeAgo_Yesterday" xml:space="preserve">
    <value>Yesterday</value>
    <comment>Yesterday</comment>
</data>
<data name="TimeAgo_LessThan1Week" xml:space="preserve">
    <value>{0} days</value>
    <comment>Less than 1 week</comment>
</data>
<data name="TimeAgo_Past" xml:space="preserve">
    <value>{0:dd/MM/yyyy}</value>
    <comment>Past</comment>
</data>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].