Wednesday, March 4, 2009

How to: Use LocaleManager

(For Part I, Introduction of LocaleManager, click here.)

It is very easy to use the locale manager. It is a standalone application that runs on window.
The executable and some test input files can be downloaded from
Github
To use it, just follow the screen captures.

1. Start the program. Then select base locale directory, e.g. en_us.
































2. After clicking ok, the base locale name will be shown in red color on the dialog. Also the sibling sub-directories will be displayed in the list box on the left as existing locale. For anybody using subversion, the svn directory also showed up and that shouldn't be selected as a target locale.































3. After selecting locales to work on, click Load and the worksheet will show as follows. My test input files only have 3 lines so it doesn't look impressive. This window is resizable. This worksheet form shows the resource name, its value in base locale and values in selected locales. It is very easy to see which ones are not translated yet.

The target locale file will be reorganized to use the same resource entries as in base. Any entries that exist in base but not in target will be added to the target locale with a blank value. Any entries that exist in target but not in base will be taken out and save to a Mismatch_timestamp.log located in the same folder as the .exe file.

Click Save Changes before close the window and changes made will be saved to target file. Base file will not be touched.










A new feature I just added is the Translate function. You can simply double click on an item under a target locale column, that item will be translated. A message box will pop up to ask you if you want to use that translation to replace the existing one.

The default translator is Microsoft Translator. Not all languages are supported by Microsoft right now. So you can use the menu to select Google Translator to see if your language is supported. I checked a few languages to make sure that the request will get some good response. Such as for Chinese, the parameter I pass to Microsoft Translator is "zh-CHS", but for Google, I need to use "zh_cn". So if you don't get any result from either of the translator, you can try to tweak the request by simply rename your locale folder, whose name is used by LocaleManager to send request to Microsoft or Google.

When you want all items to be translated, click on Translate All on the menu bar, the software will try to send a translate request to Microsoft or Google to translate "Hello World". So take a look at the returned result first. If the result is good, that means all the parameters and your internet connection is working well. If the result is not good or some errors returned, click "No" on the MessageBox to cancel the translation. Click "Yes" will only be a waste of time.

When you have many items to translate, the UI may appear to be frozen. But just leave it like that. It is going to come back when it is done. When I get some time, I can try to add more codes to make the UI more responsive.


WebORB Rocks!

The situation that leads us into using WebORB is that we use C# and SQL server on the server side with Flex on client side. The communication has been through SOAP. The SOAP packages can be really bulky sometimes. Performance was not extremely bad but we are looking for better.

WebORB allows our server and clients to communicate through remote objects. I have been running load testing when we were using SOAP. After we put WebORB in place, I ran load testng again and the performance improvement was huge. Parsing XML does take time. No doubt about it.

LocaleManager - a practical tool to manage resources files of different locales for Flex and .NET

A problem I have been facing recently during Flex development is that the en_US base locale files change from time to time as new strings are added to codes and it is hard to keep the files for other locales in sync. I couldn't find any simple and free tool like this on the web so I decided to develop it by myself.

This app allows a user to select a base locale and any other locale or locales to work on. Then it displays the name and value of resources in a table. Users can keep track of which entries need to be translated or simply work on this table to fill all the blanks. The changes will be saved with UTF8 encoding.

It supports two types for resource files:
  • .properties files for Java or Flex
  • .resx files for .Net
The assumptions are that users follow the common practices for locale folders: use a separate folder for each locale. So they normally look like:
locale-
--- en_US - resource files in English
--- de - resource files in German
--- fr - resource files in French
For .Net Developers, you can refer to my article about ResourceBundle to see how it is possible to organize resource files this way for .Net applications including WPF applications.

This tool can be downloaded from Github.

It is a C# implementation. The sources for the initial version are also available on Google, but later I started using my own svn and the codes on Google are far from the latest.

Here is the link on How to use the tool.

Or see the post on CodeProject.

NUnit versus Visual Studio 2008's Test Project for Unit Testing on C# codes

I've seen people asking about which unit test tool to use and would like to talk about my experience with NUnit and Visual Studio 2008.I started unit testing with NUnit and loved it and the idea of unit testing. The good things about it are:
It is easy to get started.
It has a very good user interface, simple but elegant. It shows everything you will want to see from unit test results.
It runs fast.
Tests can be run from inside Visual Studio so you can debug the codes if needed. I know it can plug into Visual Studio but never tried that. The way I use it is to set my unit test project's Start Up application as NUnit.exe in the project's debug configuration.
Tests can also be run by using NUnit's UI only if you want to see some quick results.When I started using Visual Studio 2008, I noticed that in the Add an item menu, there is an option to add a Unit Test. I started to try it. At the beginning, I still prefer NUnit. But now I would recommend people to use Visual Studio 2008's unit test for the following reasons:
VS's unit test codes can be generated automatically. This saves a lot of typing. It's not a big deal though if you want to organize the codes in your own way. But it is a very powerful and impressive feature.
VS's unit test allows you to test private functions. This is something I wished NUnit would have when I was using NUnit. There are simply some important private functions that need to be covered with Unit Test. I don't want to change them to public in order to test them.
The most compelling reason that I want to stick with VS unit test is that these tests can by used by Team System's load test directly. I recently started working on load testing with Team System. It is very powerful load testing tool. It can be created by selecting unit tests or web tests. If the codes being tested are for a server and load is a concern, it is better to create VS unit tests so they can be used for load tests later.It is possible to use both though by using some conditional compiling settings. But I feel it will be easier to deal with one tool only.