Skip to content
ROG edited this page Feb 15, 2022 · 7 revisions

Welcome to the GlobalStrings wiki!

GlobalStrings is a package that helps manage strings for implementing new languages in .NET applications.

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);
}

Wiki Sections

  1. Instalation
  2. Globalization
  3. GlobalGlobalization
  4. LanguageInfo and TextBookCollection
  5. JSON Serialization
  6. GlobalizationJsonSerializer

Links