VOOZH about

URL: https://www.nuget.org/packages/LinePutScript.Localization.WPF/

⇱ NuGet Gallery | LinePutScript.Localization.WPF 1.0.7




👁 Image
LinePutScript.Localization.WPF 1.0.7

dotnet add package LinePutScript.Localization.WPF --version 1.0.7
 
 
NuGet\Install-Package LinePutScript.Localization.WPF -Version 1.0.7
 
 
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.WPF" Version="1.0.7" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LinePutScript.Localization.WPF" Version="1.0.7" />
 
Directory.Packages.props
<PackageReference Include="LinePutScript.Localization.WPF" />
 
Project file
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.WPF --version 1.0.7
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LinePutScript.Localization.WPF, 1.0.7"
 
 
#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.WPF@1.0.7
 
 
#: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.WPF&version=1.0.7
 
Install as a Cake Addin
#tool nuget:?package=LinePutScript.Localization.WPF&version=1.0.7
 
Install as a Cake Tool
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应用程序支持多语言

  • 支持文本和数值 - 不同语言的控件位置大小
  • 支持翻译接口 - 用于网络翻译等
  • 支持自动生成所需翻译文档

如何使用

安装

  1. 通过Parckage Manager
Install-Package LinePutScript.Localization.WPF
  1. 通过nuget.org

    LinePutScript.Localization.WPF

在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 net6.0 net6.0 is compatible.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Framework net462 net462 is compatible.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on LinePutScript.Localization.WPF:

Package Downloads
VPet-Simulator.Core

虚拟桌宠模拟器 一个开源的桌宠软件, 可以内置到任何WPF应用程序

VSpiritBeast.Core.Interface

Package Description

VSpiritBeast.Core

Package Description

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on LinePutScript.Localization.WPF:

Repository Stars
LorisYounger/VPet
虚拟桌宠模拟器 一个开源的桌宠软件, 可以内置到任何WPF应用程序
LorisYounger/VPet.Plugin.Demo
由开发者制作的桌宠插件案例, 这算是代码嵌入类型MOD的DEMO
Version Downloads Last Updated
1.0.7 3,776 4/20/2024
1.0.6 3,903 7/3/2023
1.0.5 287 7/3/2023
1.0.4 269 7/3/2023
1.0.3 299 6/30/2023
1.0.2 293 6/30/2023
1.0.1 288 6/30/2023
1.0.0 297 6/30/2023

1.0.1: 支持StringFormart
1.0.2: 支持快捷调用
1.0.3: 双项绑定兼容
1.0.4: 换行符(\n)兼容
1.0.5&6: 换行符(\r)兼容
1.0.7: 相关类转换为public