C # localization

Possible duplicate:
C # localization really confusing me

Could you share your localization steps for huge C# applications?

I am sure that a basic resource-based strategy can work when it comes to small and medium-sized projects.

However, if we are talking about large products, this approach should be combined with custom build steps and some third-party applications used specifically by linguists.

So, could you advise / share some global localization strategy that is used in your applications (big enough, obviously :)

Thanks.

+6
source share
2 answers

A basic resource-based strategy works even in large enterprise applications. This is a built-in and easy to understand solution, so every programmer can use it without any problems.

The only problem: you need to somehow convert your resource files into translation memory files (i.e. tmx) and vice versa - so that translators can use their standard tools.

So, you really need a localization process. Is this different for large applications? Well, if you set up the right process, it will scale. Now on to the process. From my point of view, it should look like this:

  • Copy the resource files to the appropriate folder structure (localization engineers should not work directly with the application code base). The corresponding folder structure should be somehow similar to:
    [The name of the project]
    .
    .
    [neutral] [German] [Japanese] [French]
    .
    .
    (each folder contains translatable resources in a given language; neutral is usually English)
    Of course, you need to somehow transform the code base into a folder structure, but it can be automated.

  • Process your translatable resources and create tranks - zip archives containing files that need to be translated (in this case they seem to be all). The files should probably be converted, so you will not be able to send resx files. The conversion application should read the contents of the resx files and put the translatable strings in some format file agreed with the translators (this may just be Excel, but I will not recommend this solution). Now I can’t name the names of such tools, although I know that there are some commercial applications, since I worked only with custom ones.

  • Send transkits to translators (most likely to translation providers).

  • After receiving the translated files (transkit) back, you need to check it (this step is crucial). You need to make sure that the transkit is complete (i.e. there are no translatable lines) and is technically correct (that is, the file encoding is correct, usually UTF-8 or UTF-16). It is also at least useful to take a look at the file to see if there are any weird characters like 1/2, 3/4 or something else - this usually means a broken encoding.

  • Import the transkit. This is the reverse step 2 - you need to translate the lines back to the appropriate files.

  • Copy the translated files back to the source code base and run the Localization assembly.

  • Check the application for localization problems (i.e., overlapping controls, line cuts, incorrect encoding, etc.), this usually means that i18n is not running correctly).
  • Fix localization / internationalization errors (localizability).
  • Go to 1 until the user interface / line wait period is frozen. This implies that translators will use some Translation Memory and will not charge (or charge less) for re-translating previously translated lines.
  • Automation of all possible steps and completed actions.

In addition, you cannot establish your general glossary of terms and conduct a linguistic review of the translated content.

+2
source

I think you can rely heavily on the resource infrastructure provided by .NET with a few changes to make it more suitable for large projects, namely to create and maintain resources independent of the application and to eliminate the generated properties that apply to each resource by name. If there are other objectives suitable for large project localization that are not discussed below, describe them so that I can consider them.

  • Create a stand-alone project to represent your resources, which can be loaded as a separate DLL.
  • Add the “Resources” file to the project by selecting the link on the “Resources” tab of the project properties: “This project does not contain the default resource file. Click here to create it.”
  • Add another resource with the same root name to represent another language, for example, "Resource.de.resx" for German. (Visual Studio apparently uses the file name to determine the language that the resource file represents). Move it to the same directory / folder as the default resource file. (Repeat for each language.)
  • In the properties of the Resources.resx file, remove the "ResXFileCodeGenerator" from the Custom Tool property to prevent the generation of default code in the namespace of the Properties application. (Repeat for each language.)
  • Explicitly / manually declare your own resource manager, which loads the newly created resources using a line, for example:

    static System.Resources.ResourceManager resourceMan = new System.Resources.ResourceManager ("LocalizeDemo.Properties.Resources", typeof (Resources). Assembly);

  • Implement a file that can be generated containing a list of all resources that you can reference (see Figure 1)

  • Implement a function to extract and format strings (see Figure 2).

  • Now you have enough so that you can refer to translated strings from any number of applications (see Figure 3).

  • Use System.Resources.ResXResourceWriter (from System.Windows.Forms.dll) or System.Resources.ResourceWriter (System.dll) to generate resources instead of the Resx files being your main source. In our project, we have an SQL database that defines all of our lines in each language, and part of our build process generates all the Resx files before creating the resource project.

  • Now that you can create your Resx files from any format, you can use any format you want (in our case, the SQL database that we export and import from Excel spreadsheets) to provide files for sending to translators.

  • Also note that translated resources are built as satellite dlls. You could build each language yourself using the right command line tools. If this is part of your question (how to do this) let me know. But at the moment, I assume that you know about this, since the steps of custom assembly have already been mentioned.

Figure 1 is an enumeration identifying all available resources:

 namespace MyResources { public enum StrId { Street .... } } 

Figure 2 - Code for loading and returning formatted resource strings:

 namespace MyResources { public class Resources { static System.Resources.ResourceManager resourceMan = new System.Resources.ResourceManager("MyResources.Properties.Resources", typeof(Resources).Assembly); public static string GetString(StrId name, System.Globalization.CultureInfo culture = null, params string[] substitutions) { if (culture == null) culture = System.Threading.Thread.CurrentThread.CurrentUICulture; string format = resourceMan.GetString(name.ToString(), culture); if (format != null) { return string.Format(format, substitutions); } return name.ToString(); } } } 

Figure 3 - Access to resources:

 using MyResources; namespace LocalizationDemo { class Program { static void Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE"); Console.WriteLine(Resources.GetString(StrId.Street)); } } } 
+2
source

Source: https://habr.com/ru/post/892417/


All Articles