Practical ASP.NET Localisation File Management in Visual Studio
The Problem
You are working on an application to be used across multiple countries by users with different languages. You need to quickly and automatically generate localisation files and distribute all text that needs to be localised to the client. The text should be distributed in a simple easy to understand layout for translation and the localised text needs to be brought into the system quickly and as effectively as possible.
The Solution
And you are in luck, since I know a sneaky little Visual Studio Extension package that will make take some weight off your shoulders. The answer bears the name of “ResX Resource Manager”.
You are working on an application to be used across multiple countries by users with different languages. You need to quickly and automatically generate localisation files and distribute all text that needs to be localised to the client. The text should be distributed in a simple easy to understand layout for translation and the localised text needs to be brought into the system quickly and as effectively as possible.
How we solved localisation
Due to the nature of our project, it was decided to use MS resource files (resx files) in order to handle localisation. These files have a specific structure in how they are used and named in order for ASP.NET to match the appropriate language text to the specified authenticated uses language and culture. In most part, this is handled for us by the extension as you would soon see. The basic idea is that the resource files are named in a manner that matches with a specific culture.
The resource files (using the same text) all contain corresponding keys, where the values contain the localised text of the corresponding value in the other resource file.You can find more information on resource files and how to use them on MSDN from here or here.
It was important for us to reuse some text across multiple places within the project. Furthermore, the client was being charged R1.50 per word for translation. It was thus important to ensure that our localised text was properly structured with minimal text duplication, while keeping language context in mind.
The translators also refused to work on files containing any “code-like” text and were only interested in the text that they needed to translate and a work area in which to translate the text.
How It Helps You
Some important adnvantages of using the ResXManager extension and why it suited our needs include:
-
It automatically identifies all resource files
-
Allows you to specify all languages you are using
-
Auto generates language resx files (matching language cultures)
-
Exports all resource files into Excel
-
Easy to find untranslated strings
-
Automatic translation ( NOT recommended)
-
Export translations with columns for additional language translations
-
Import Translated Excel files into the prices
How to Install it
-
Open your Visual Studio Project
-
Navigate to “Tools” >> “Extensions & Updates”
-
Go to “Online” search and search for “ResXManager”
-
Click Install and wait for ResX Manager to install
Using RESX Manager
After completing the installation (and restarting Visual Studio) you will find ResX Manager under “Tools”. Go ahead and open ResX Manager.
You should now see the manager open and looking somewhat like the image below (without the translated text). The red cells are un-localised fields where greyed-our red fields mean that the alternative language resx file has not yet been created. Simply double click on any of these cells and the missing files will automatically be generated and added to your project.
The “Translate” tab is where you can automatically have your files translated. This is not recommended due to some bugs that exist with the auto translation. The “Configuration” tab is where you adjust basic settings such as your default resource language, excel import settings, etc.
The last Tab is the “Languages” tab where you can double click on any language to add it to your project.
Clients Love Excel
Finally you can give your client and exported Excel file of your files without any debate or hassle. You can export all the text in all your resource files to Excel, by quite simply going to the “Main” tab, clicking on the Excel icon and selecting “Export All”. Select a save location for your Excel file and run the export.
Import can be done in the same, why by just clicking on “Import”. The only requirement is that the Excel sheet (or file depending on your ResXManager configuration) is in the same format as how it was exported.
Opening up the Excel file, you will see a format similar to the one below. How you handle and/or distribute this file is up to you, but I have some recommendations about what worked for me.
My personal recommendation for import/exporting
“We don’t want to see code!” “But it’s not code, it’s just some keys or variable so we can identify the text.” “Don’t make this technical, we just want the words to be translated. Nothing more! ”.
This is the kind of reaction you can expect from most clients if you present them with the Excel file in the format in which it was exported. Besides, it’s not wise to expose your resx keys to others as a simple typo can cause big issues in your files and/or code.
The solution is quite simple, make a copy of the exported file and add a new top row with more descriptive information. Lock and hide all the cells that the translators do not need to see and password encrypt the sheet so that only the alternative language fields can be edited. You can style the sheet whichever way you prefer, but below is an example of how you can setup the excel file to send off to the translators/clients.
Unmodified Excel Import/Export
Modified Excel File with Columns Hidden