Skip to content

๐ŸŒ Simple package that helps manage strings for implementing new languages in .NET applications.

License

Notifications You must be signed in to change notification settings

LuanRoger/GlobalStrings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8f2e056 ยท May 6, 2022

History

43 Commits
Apr 9, 2022
May 6, 2022
May 6, 2022
Jun 9, 2021
Jun 11, 2021
Feb 15, 2022

Repository files navigation

GlobalStrings

Simple package that helps manage strings for implementing new languages in .NET applications

Dependencies

Installation

PM

Install-Package GlobalStrings

.NET CLI

dotnet add package GlobalStrings

See also in Nuget Packages

Simple example:

using System.Collections.Generic;
using GlobalStrings;

private Globalization<string, string, int> _globalization { get; set; }
private LanguageInfo<string, string, int> languagePtBr => new("pt_br", new(new()
{
    { "Home", new()
    {
        {0, "Olรก"},
        {1, "Seja Bem-Vindo"}
    }}
}));

private LanguageInfo<string, string, int> languageEn => new("en_us", new(new()
{
    {"Home", new()
    {
        { 0, "Hello" },
        { 1, "Wellcome" }
    }}
}));

private string congrats;
private string wellcome;

public void ChangeLanguageTest()
{
    StartGlobalization();
    Assert.Equal("Olรก", congrats);
    Assert.Equal("Seja Bem-Vindo", wellcome);

    _globalization.UpdateLang("en");

    Assert.Equal("Hello", congrats);
    Assert.Equal("Wellcome", wellcome);
}

private void StartGlobalization()
{
    _globalization = new(new() { languagePtBr, languageEn }, "pt_br");
    _globalization.LangTextObserver += Globalization_LangTextObserver;
    _globalization.StartGlobalization();
}

private void Globalization_LangTextObserver(object sender, UpdateModeEventArgs updateModeEventArgs)
{
   congrats = _globalization.SetText("Home", 0);
   wellcome = _globalization.SetText("Home", 1);
}

Documentation

Access the documentation here.