mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-18 22:46:38 +08:00
61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
using Acme.LocalizationComponent;
|
|
using Acme.LocalizationComponent.Localization;
|
|
using Acme.LocalizationConsumer.Localization;
|
|
using AtomUI;
|
|
using AtomUI.Localization;
|
|
using Avalonia;
|
|
using Avalonia.Headless;
|
|
|
|
namespace Acme.LocalizationConsumer;
|
|
|
|
public static class Program
|
|
{
|
|
public static int Main()
|
|
{
|
|
AppBuilder.Configure<FixtureApplication>()
|
|
.UseHeadless(new AvaloniaHeadlessPlatformOptions())
|
|
.SetupWithoutStarting();
|
|
|
|
var application = Application.Current ?? throw new InvalidOperationException(
|
|
"The fixture application was not initialized.");
|
|
var localizer = application.GetLocalizer() ?? throw new InvalidOperationException(
|
|
"The fixture localizer was not registered.");
|
|
var manager = application.GetLanguageManager() ?? throw new InvalidOperationException(
|
|
"The fixture language manager was not registered.");
|
|
|
|
if (localizer.Get(AppLangResourceKind.Title) != "Language pack fixture" ||
|
|
localizer.Get(WelcomeLangResourceKind.Greeting) != "Welcome")
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
manager.ChangeLanguage(LanguageTags.JaJP);
|
|
if (localizer.Get(AppLangResourceKind.Title) != "言語パック フィクスチャ" ||
|
|
localizer.Get(WelcomeLangResourceKind.Greeting) != "ようこそ" ||
|
|
localizer.Format(WelcomeLangResourceKind.ItemCount, 3) != "3 件の項目があります。")
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
Console.WriteLine(
|
|
$"ja-JP:Welcome={localizer.Get(WelcomeLangResourceKind.Greeting)};" +
|
|
$"ItemCount={localizer.Format(WelcomeLangResourceKind.ItemCount, 3)}");
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
public partial class FixtureApplication : Application
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
this.UseAtomUI(builder =>
|
|
{
|
|
builder.UseLanguages(
|
|
LanguageTags.EnUS,
|
|
[LanguageTags.EnUS, LanguageTags.JaJP]);
|
|
builder.UseLocalizationComponent();
|
|
});
|
|
}
|
|
}
|