C#multi-language tool- ResX Manager

C#multi-language tool- ResX Manager

This article is not to introduce how to internationalize the project. It mainly introduces a `VS` extension that can easily manage common resource files (*.resx)

最后更新 2/16/2021 10:23 PM
沙漠尽头的狼
预计阅读 4 分钟
分类
.NET WPF
标签
.NET C# WPF internationalization Visual Studio

There are many ways to realize WPF internationalization:

  1. You can use xaml resource files (*.xaml) to store content displayed in various languages. I have introduced it in another number:
  1. Universal resource files (*.resx) can also be used. This method is not limited to project templates and can be applied to other project types. C/S, B/S, App(Xamarin), etc. can be used.

本文不是要介绍怎样实现项目国际化,主要是介绍一款VS扩展程序,可方便的管理通用的资源文件(*.resx),比如下面这样:

Manage multiple resource files with ResX Manager

使用ResX Manager管理多资源文件

** Conveniently: **

  • One interface lists all resource files for the entire solution
  • International resource files of the same project can be managed by comparison with one interface

按多语言资源文件命名规则,相同前缀的资源文件,后缀(.resx 前的一小部分)区分不同语言,比如UiResource.zh-CN.resx为简体中文,UiResource.resx为默认语言,其他语言扩展只需要增加一个资源文件,修改后缀即可。

Compare the effect of directly opening resource files:

Default language resource file

默认语言资源文件

Simplified Chinese resource file

简体中文资源文件

There are only two files above that support more international languages. For every time a translation or modification is added, you have to double-click all resource files. How tiring would it be?

Simply laying the groundwork, let's talk about how to install the plug-in and how to use it.

1 is mounted

请到 ResXManager 发布地址下载安装:

插件详情

或者VS扩展中搜索ResX Manager安装:

VS扩展搜索安装

2 Function description

2.1 Unified management and modification of various resource documents

见本文第一张图(来自乐趣课堂 WPF 项目资源文件),左侧展示解决方案中所有工程的资源文件结构、位置,选择某资源文件后,右侧展示资源文件中的键及键对应的各语言翻译文字,同一名命名规则的资源文件可同时进行编辑。

2.2 check for missing

如下图,SearchStartTime键对应的中文缺少翻译,输入框有红色背景提示,此时可直接进行即时输入翻译。

Missing translation mark

漏翻译标识

如果键较多,或者支持的语言较多,可点击下面的翻译切换,一般我在上面这里就直接修改了,下面的这个界面我很少操作:

  • 切换翻译 Tab
  • Enter untranslated language
  • Click Start and Apply All to apply the modified translation to the corresponding resource file

Clearly display the language to be translated

清晰显示待翻译的语言

2.3 Exporting and importing Excel files

当多语言翻译工作量较大,或者某一语言需要专业人士协助,让别人使用Visual Studio来编辑资源文件是不太合理的,这时使用导出功能将指定的资源文件导出为 Excel 格式,直接填写缺漏部分,再将完善的 Excel 文件导入自动更新各资源文件。

导出资源文件为Excel

也可以选择需要翻译的资源文件对应的键,选择导出所选,导出文件如下,红框处为刚输入的简体中文翻译文。

编辑导出的Excel文件

As shown in the figure above, after completing the translation, you can select import.

Is this extension convenient? Welcome to leave messages and exchanges.

Keep Exploring

延伸阅读

更多文章
同分类 / 同标签 5/27/2025

WPF achieves a danger warning effect

When the program we write is released, the user is doing some dangerous operations. Our software should give some reminder effects, such as red on the edge of the border, similar to the alarm reminder effect like Gaode Map

继续阅读
同分类 / 同标签 1/26/2025

WPF internationalizes with custom XML files

This article describes in detail the methods of using custom XML files to achieve internationalization in WPF programs, including installing the necessary NuGet package, dynamically obtaining language lists, dynamically switching languages, using translation strings in code and xaml interfaces, etc. It also provides source code links to help developers easily internationalize WPF applications.

继续阅读