LinePutScript.Localization
1.1.0
dotnet add package LinePutScript.Localization --version 1.1.0
NuGet\Install-Package LinePutScript.Localization -Version 1.1.0
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="LinePutScript.Localization" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LinePutScript.Localization" Version="1.1.0" />
<PackageReference Include="LinePutScript.Localization" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LinePutScript.Localization --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LinePutScript.Localization, 1.1.0"
#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.
#:package LinePutScript.Localization@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LinePutScript.Localization&version=1.1.0
#tool nuget:?package=LinePutScript.Localization&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
LinePutScript.Localization.WPF
<img src="https://github.com/LorisYounger/LinePutScript.Localization.WPF/raw/main/Localization.png" alt="Localization" style="zoom:50%;" />
WPF本地化类库, 轻松让你的wpf应用程序支持多语言
- 支持文本和数值 - 不同语言的控件位置大小
- 支持翻译接口 - 用于网络翻译等
- 支持自动生成所需翻译文档
如何使用
安装
- 通过Parckage Manager
Install-Package LinePutScript.Localization.WPF
通过nuget.org
在XAML中引用
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
开始翻译
<Label Grid.Row="0" Content="请选择当前语言" Padding="0" VerticalAlignment="Center" Margin="5,0,0,0" />
<Label Grid.Row="5" VerticalAlignment="Center" Padding="0" Margin="5,0,0,0">
<Run>显示的内容是:</Run> <Run Text="{Binding Text,ElementName=txtInput}" />
</Label>
<Label Content="快捷翻译当前软件" Grid.ColumnSpan="1" FontSize="16" />
<Label Grid.Row="0" Content="{ll:Str 请选择当前语言}" Padding="0" VerticalAlignment="Center" Margin="5,0,0,0" />
<Label Grid.Row="5" Content="{ll:Str 显示的内容是\:{0}, ValueSource={Binding Text,ElementName=txtInput}}" VerticalAlignment="Center" Padding="0" Margin="5,0,0,0" />
<Label Content="{ll:Str 快捷翻译当前软件}" Grid.ColumnSpan="1" FontSize="{ll:Dbe smsize, DefValue=16}" />
简单来讲,就是在原先的基础上多加个 {ll:Str 原先的内容} 就可以了
并且修改是及时显示的, 并不会导致设计器无法查看最新的设计, 所见即所得
支持的翻译类型
| 类型 | 描述 | 类型 |
|---|---|---|
| Str | 文本 | String |
| Bool | 布尔 | Boolen |
| Dbe | 浮点 | Double |
| Int64 | 长数字 | Long |
| Int | 数字 | Int32 |
添加翻译文档
// 本地化:
// 开启翻译存储, 储存所有未翻译的文本,可以在 LocalizeCore.StoreTranslationList 中查看所有未翻译过的文本
LocalizeCore.StoreTranslation = true;
// 加载所有的本地化语言, 通过 LocalizeCore.AddCulture
foreach (var path in new DirectoryInfo(Environment.CurrentDirectory).GetFiles("*.lps"))
LocalizeCore.AddCulture(path.Name.Split('.')[0], new LPS_D(File.ReadAllText(path.FullName)));
// 加载当前用户使用的默认语言
LocalizeCore.LoadDefaultCulture();
获取未翻译过的文本
//在初始化之前先 开启翻译存储, 储存所有未翻译的文本
LocalizeCore.StoreTranslation = true;
//打开程序后在所有UI界面逛一遍,接着获取下面这个List里的文本即可
LocalizeCore.StoreTranslationList;
//或者通过下面这个方法获得制作好的LPS格式文件,可以直接储存
LocalizeCore.StoreTranslationListToLPS();
翻译接口
//翻译接口,实现这个方法以支持自定义翻译
LocalizeCore.TranslateFunc = (txt) => {
//从网络获取翻译等等
return txt;
}
快捷翻译
通过Demo项目 (可在Release中下载), 可以加载LPS文件进行快速翻译. 例如将翻译文本扔到网络翻译中,然后在复制粘贴回来
详细了解: Demo
详细请参见DEMO文件
其他
附语言表 https://learn.microsoft.com/en-us/windows/win32/wmformat/language-strings
顺带一提, 语言采用的是向上兼容, 不用担心填写 zh-CN 还是 zh-Hans 还是 zh, 均会历遍到
| Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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
- LinePutScript (>= 1.11.9)
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.1.0 | 81 | 9/1/2026 |
跨平台本地化类库