4
votes

As part of internationalizing our application which is based on asp.net, c#, silverlight, XBAP, I'm evaluating approaches to start with. I'm having to chose between GNU gettext()(PO files) and Microsoft's resource(resx) based approach. So at this juncture, I'm trying to understand what is the best way to extract localizable strings from .cs files, aspx, ascx, xaml (silverlight) files to resource files(resx) automatically if I have to go the MS way.

I have below options in mind:

  1. Resource Refactoring tool, but it extracts all strings (no matter if you have to translate or not) like page headers etc. And we cannot mark or exclude particular strings. Or we will have to manually select each string and then extract (right click and click extract).
  2. Resharper's Localization assistance, here I do not see the automatic extraction, but I'll have to manually extract string by string.

I know there has to be a bit of manual intervention, but any advise would help in choosing the right direction, between gettext()(gnu gettext() c# or fairlylocal or MS localization approach.

1
If you are using VS 2010 then easiest way to localize aspx/ascx can be to use Tools->Generate Local Resource in design view. Also, don't forget to include java-script and images in your potential localization targets. Finally, it doesn't really matter if all strings are extracted for localization - if you don't want to localize some resource then leave it out from locale specific resource file. The default logic would fall-back on culture-neutral resources for the value.VinayC
@VinayC: That does the trick for aspx/ascx, but I'm looking for a solution that would extract from source code and xaml too. Also, a resource file per page (or user control) looks more cumbersome when I have around 300 pages to handle, I hope we can club those in to one (with de-duping if there are any), but not sure on performance implications.gsk

1 Answers

7
votes

Both the approaches have pros and cons, lets discuss.

FairlyLocal

(GNU Gettext) first, initial tweaking is required:

  1. download library & tools and dump at some place relative to your project
  2. modify the base page object of your site (manual intervention)
  3. add a post-build step to your web project that will run xgettext and update your .po files

second, strings extraction has been taken care-of by FairlyLocal itself. third, translation of strings could be done in-house or outsourced as PO files are widely known by linguists. fourth, rendering of a few UTF-8 chars (if any) depend on webfonts {eot (trident), svg (webkit, gecko, presto)}. fifth, locale needs to be maintained (like pa-IN languageCode-countryCode). sixth, several converters are available for PO files. seventh, the default logic will fall-back on default-locale (en-US) resources for the value. an issue, The .po files that the build script generates won't be UTF8 by default. You'll need to open them in POEdit (or similar) and explicitly change the encoding the first time you edit them if you want your translated text to correctly show special characters.

MS localization

first, extraction of strings is pretty easy using Resource Refactoring Tool. second, resgen.exe command-line tool could be used to make .resx files linguists friendly.

resgen /compile examplestrings.xx.resx,examplestrings.xx.txt

third, Localization within .NET (not specific to ASP.NET Proper or ASP.NET MVC) implements a standard fallback mechanism. fourth, no dependency on GNU Gettext Utils. fifth, can achieve localization from Strings to Dates, Currency, etc. using CurrentUICulture and CurrentCulture. sixth, webfonts are recommended here too.

thanks.