Localization

Sep 14, 2009 at 11:05 AM

Moses,

Let's start here talking about this very important matter and see what other members have to say

As said in another thread, the hard part of localization is JS scripts
I did not really worked on it
I just evaluated the problem and googled a lit bit
As all Kigg JS scripts are rendered in one compressed file, I found that the best solution is to write an httphandler that analyzes this file and translates its content on the fly
I took this idea from here : http://madskristensen.net/post/Localize-text-in-JavaScript-files-in-ASPNET.aspx

Sep 22, 2009 at 5:41 AM

The idea of translating files on the fly is great. Personally I think it would be enough just to have all those js string in one separate file so I don't have to go through all of the files in order to find all of them. It's difficult to merge with new version when I have to compare also changes in strings.

Regards,
Pawel

Coordinator
Sep 22, 2009 at 6:07 AM

I guess it should be single javascript file with different localization e.g. messages.js.en-US, messages.js.ar-EG etc....

As I remember this is how it is implemented in Mad's post

Sep 25, 2009 at 5:04 AM
Edited Sep 25, 2009 at 1:23 PM

No, for me the idea is to put translated messages into classical .NET resources files
In js files, we replace a hard coded text by something like
GetGlobalResourceObject("KIGG" "MSG_INFO")
And whenever the httphandler encounters this text, it will go and bring it back from the resource file
At least that's the way I understood the link I gave in my first thread

This is a very easy solution.

On the other hand, there is no need to gather all js files in one big file
The KIGG scriptManager does this automaticallement for us

I am also wondering if we cannot just add a private method to the AssetHandler class that does the translation before the compression.
An option in the web.config will enable or disable this possibility

Sep 27, 2009 at 8:58 AM
Edited Sep 27, 2009 at 9:29 AM

Very good news

This morning, I easly added a TranslateScript method to AssetHandler class
I took the code mentionned here : http://madskristensen.net/post/Localize-text-in-JavaScript-files-in-ASPNET.aspx
I added the call to this method inside the ProcessRequest method.
Just here

 // Write
using (StreamWriter sw = new StreamWriter(response.OutputStream))
{
    //sw.Write(asset.Content);

    string translated = TranslateScript(asset.Content);
    sw.Write(translated);
}

I created a global resource file and started translating messages in Membership.js

I realized then those hard coded messages are not really used by the application
The application always uses its internal message and ignores js messages
So It looks like there is no need to translate any js message

 

Sep 27, 2009 at 2:50 PM
Edited Sep 27, 2009 at 3:46 PM

Actually some hard coded messages are still used
Membership.js uses mainly the JQuery Validation Plugin.
This plugin uses JSON to communicate with the application

Anyway, on the other side my, on the fly, translation is working perfectly

Jan 3, 2011 at 2:33 AM

Are there any plans to continue with localization of other parts of the website?