Skip to content

tifish/Jeek.Avalonia.Localization

Repository files navigation

Jeek.Avalonia.Localization

Avalonia string localization support.

  • Switch language at runtime.
  • Customizable language file format and location.
  • Simple interface, simple implementation.

Usage

  • Use localized string in .axaml:
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        
        xmlns:l="using:Jeek.Avalonia.Localization"

        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="Jeek.Avalonia.Localization.Example.MainWindow"
        Title="Jeek.Avalonia.Localization.Example">
    <StackPanel>
        
        <!-- Get the string with key Welcome -->
        <Label Content="{l:Localize Welcome}" />
        
    </StackPanel>
</Window>
  • Json language file Languages\en-US.json:
{
    "Welcome": "Welcome to Avalonia!"
}
  • Switch language:
Localizer.Language = "en-US";
  • Get localized string in code:
Localizer.Get("Welcome");

Origin

About

Avalonia localization support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages