[Source code] Sailingease. NET resources Tool (. NET multi-language resource editor)

Source: Internet
Author: User

I posted a blog post in October 2016 that introduced a multilingual resource file Editor I wrote, and was released as a free software release.

Have received some feedback from friends, friends are very enthusiastic to mention a lot of suggestions and concerns, and friends send red envelopes to come, let me very touched.

It is also a simple project based on the Sailingease Winform framework that uses the modularity, common controls/components, Automatic Updates, and so on, provided by the Sailingease Winform framework.

Now the software in the application layer source code 100% through a read-only way to open source , you can browse online through the browser:

http://sourcecode.shengxunwei.com/ssr/

Through the source code, you can visually see the specific implementation of the software, understand the design and implementation of a modular Winform application, but also includes a Winform common control package, I was written in GDI, interested friends can also learn to use GDI to write Winform Control methods and patterns, as well as an overview of the specific application examples of the sailingease Winform Framework. The functional module of this software is not complex, it is believed to be a good sailingease Winform Framework starter project.

Most of the code was written around 2010 (7 years ago), so there are some poorly thought-out areas where the master should not laughed at.

Next I will open up the software/components I wrote in the same way.

Open source in a read-only way, please forgive me, not the open source community will also admit: open source! = Free? :)

For the Sailingease Winform Framework, you can refer to:

Http://www.cnblogs.com/sheng_chao/p/6084144.html

The following is a detailed description of the original blog and software of the sailingease. NET Resources Tool:

================

This is one of the small projects that I extended when I wrote the Winform IDE (http://www.cnblogs.com/sheng_chao/p/4387249.html) Project about 2010 years ago.

Originally existed in the form of shared software.

Later busy with other things, no energy to take care of, was the snow, recently smoked a few days, the software registration verification related logic has been removed, in full free form release, I hope to be useful to everyone.

Pain point:

Often, in order for the software to support multiple languages, we use. NET-brought resource files to store different language resources, load and invoke them in the program, but for large engineering or team development, including the evolving version, there are a lot of factors that are not controllable, such as the following:

1) In the past, the method of resource invocation is mainly obtained by using string as key, while the developer can get a spelling error when obtaining resources.
2) When revising the resource file, the original resource file identification has been modified, but not synchronized to the program;
3) When revising the resource file, delete the original resource entry by mistake, or remove the entry which is mistaken for being in use but is still in place.
4) It is not possible to know the use of a resource text: whether it is in use, whether it is used in multiple places.
5) When language resources are added, it is difficult to ensure that all language resources are fully synchronized, especially when the number of resources is large and the number of revisions is greater;

If a resource is invoked using a string as a key, none of the above problems can be statically checked at compile time, which means the error is difficult to find.

There are also two issues that make it cumbersome to process resource files during development:

1) in the VisualStudio directly edit the resource file, only one file for a single edit, such as Chinese and English two resource files, I need to open two separate windows to edit, to switch back and forth, and most importantly, VisualStudio Not to check your two resource files in the entries, is not one by one corresponding, they did not have any connection and mapping of such a relationship, one of the resources file more than one or less one, or key is not lowercase misspelled, are not know;

2) There is no good coordination with the translator method, such as the introduction of resources, export, automatic check; there is no good way to give the language resources to translators, and back, and in the lead back, thousands of or more resources, there is no omission, accidental deletion, no way to know.

Analysis and Conception:

We analyze the. NET-brought resource mechanism, which, after storing the resource in a resource file, generates a corresponding Designer.cs file that generates multiple corresponding Designer.cs if there are multiple language versions of the resource file, but does not abstract them.

At the time, I thought, if I could use the interface (Interface) to constrain the entity classes of different resource files and use them in the program, Discard Language.get ("key"), instead of using the interface to invoke them, we could solve the problem of 1 to 5 points above, and form the following structure:

So in the code, it completely solves the problem of the above-mentioned.

In contrast, refer to a nonexistent resource entry:

Well, the core needs will be solved.

So how do you load resources for the part of the user interface? It's pretty simple, and it doesn't need to be set up by a developer, in WinForm, just write a public class, retrieve the characters in the UI that match the specified format, and replace it with the current resource, such as:

If you are a WPF project, you can use static resource bindings directly, which is simpler than WinForm.

There are two availability issues: 1th, how do you edit multiple versions of language resources at the same time as well and quickly?

For Visual Studio, several different resource files are edited separately, as explained above: I need to switch back and forth separately, and most importantly, VisualStudio will not check the entries in your two resource files, not the one by one corresponding.

So when I was writing the sailingease. NET Resources Tool, the different resource file edits were brought together to edit a number of different resource files at the same time in one screen, and when I added a new resource file entry, as long as the operation was done once, Do not have to open each resource file to add it again (really cumbersome):

Question 2nd: How to collaborate with a translator

As mentioned above, the best way to think about it is to import and export Excel, and when it comes back, it is not complicated to check the energy efficiency:

I add a region in the software, such as "German", the software will automatically generate a list of German resources, the content of this column is now blank, I can put the current resources, together with the original language version (such as Chinese), export Excel, to translate:

The exported Excel, including the Central Plains language (such as Chinese), also includes the Comments, so that translators in translation, there is a reference to the notes, it is very convenient, after translation, and then back to the software to import.

Accessibility for efficiency: Resource row replication:

For example, a project contains "Chinese", "English", "B" project contains "English", "French", then from a project to B project to copy the resource line, can automatically paste a project in the English language resources in the B project, the Chinese resources are ignored. Even if two items are in different order of region information, they can be automatically matched.

Real-time error checking:

The problematic resource is highlighted in real time and is prompted when it is generated:

Visual Studio If you copy the resource row key is repeated, will continue to force you to break the box, or the cursor will not move, but in fact, many languages editing, I sometimes need to copy a lot of lines, and then modify their key, which is very annoying, so I write this tool when , it allows the cursor to be moved when there is an error, and does not force the need to break first, but to give the callout, just to block the build when generating the code.

Error hints in Visual Studio:

Edit multiple items at the same time

In the actual project, I am a Module corresponding to a resource project, so editing multiple projects at the same time is necessary, otherwise it is very troublesome:

Import an existing resource file (RESX file or resources file):

Welcome screen, you can open the latest project directly:

After the new project, don't forget to add the area:

Finally, after editing the resources in the software, you need to generate code to generate code for C # or vb.net, or simply to generate a resource file:

Use the generated resource files and code into the project:

Download:

I didn't find the blog. To add an attachment, the desired friend can go to my website for free download:

Http://www.shengxunwei.com

Welcome to add me QQ Exchange discussion, joint study: 279060597, and I in Nanjing, have Nanjing friends?

[Source code] Sailingease. NET resources Tool (. NET multi-language resource editor)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.