EleCho.Internationalization 1.0.4

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package EleCho.Internationalization --version 1.0.4
NuGet\Install-Package EleCho.Internationalization -Version 1.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EleCho.Internationalization" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EleCho.Internationalization --version 1.0.4
#r "nuget: EleCho.Internationalization, 1.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EleCho.Internationalization as a Cake Addin
#addin nuget:?package=EleCho.Internationalization&version=1.0.4

// Install EleCho.Internationalization as a Cake Tool
#tool nuget:?package=EleCho.Internationalization&version=1.0.4

EleCho.Internationalization

自动生成国际化字符串.
Automatically generate internationalized strings.

使用 / Usage

  1. 准备多份语言文件, 格式为 ini
    Prepare multiple language files in ini format

    Hello=你好
    
    Hello=こんいちは
    
  2. 创建一个类, 并添加 GenerateStrings 特性, 指定语言代码以及语言文件所在位置:
    Create a class and add the 'GenerateStrings' attribute to specify the language code and the location of the language file:

    [GenerateStrings("zh-CN", "/Strings/Chinese.ini")]
    [GenerateStrings("ja-JP", "/Strings/Japanese.ini")]
    public partial class AppStrings
    {
        // members will be auto generated
    }
    
  3. 类中会自动生成对应的属性, 例如名为 "Hello" 的字符串会生成 "StringHello" 属性. 当对属性取值时, 会根据其设定的 CurrentCulture, 返回对应字符串.
    The corresponding property is automatically generated in the class, for example, a string named "Hello" will generate a "StringHello" property. When a value is taken for a property, the corresponding string will be returned according to the CurrentCulture setting.

    AppStrings appStrings = new();
    
    appStrings.CurrentCulture = new CultureInfo("zh-CN");
    Console.WriteLine(appStrings.StringHello);    // Output: 你好
    
    appStrings.CurrentCulture = new CultureInfo("ja-JP");
    Console.WriteLine(appStrings.StringHello);    // Output: こんにちは
    
  4. 你也可以直接在 WPF 项目中直接将 UI 上的文本内容直接绑定到生成的属性上. 当 CurrentCulture 变更时, 会自动通知属性变更, 所以 UI 也能够自动更新.
    You can also bind the text content on the UI directly to the generated properties directly in your WPF project. When CurrentCulture changes, it is automatically notified of property changes, so the UI can be updated automatically.

    public class TestPageViewModel
    {
        public AppSettings AppSettings { get; } = new();
    }
    
    public class TestPage : Page
    {
        public TestPage()
        {
            InitializeComponents();
    
            DataContext = new TestPageViewModel();
        }
    }
    
    <TextBlock Text="{Binding AppSettings.StringHello}"/>
    
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 100 4/1/2024
1.0.1 88 4/1/2024
1.0.0 82 3/29/2024