Coffeehouse Thread

12 posts

Localizing with a database or resx files

Back to Forum: Coffeehouse
  • User profile image
    Gravy

    Hi

    I am looking in to writing a c# application in .NET 3.0 and localization has been highlighted as an issue.

    I haven't really written a localized app but I am aware of using resources and dotnets ability to choose the correct localized assembly when required.

    However, someone has suggested to me they would like to use a database in order to provide the localized strings. My first thought though would have been to use .NET resources. I can see the db approach would be more accessable to someone who didn't have any kind of resx editing tool (if there is such a thing), but I see that there is more to localization than just providing translated strings.

    Because of these conflicts of interest I wanted to ask everyones opinion:

    Is there a best practice doc anywhere?

    Has anyone localized an app using a database to provide the string and run in to problems?

    Are there tools out there to allow a non dev to manipulate .resx files when localizing?

     

    Any finally, the big question would have to be; does the current localization recommendation change if I target WPF?

    How are some of the enterprise dotnet apps out there localized? What about the Expression suite?

    Regards

    Graham

  • User profile image
    Dr Herbie

    A previous project I worked on used a database to store all GUI strings -- this not only allowed localisation, but it allows the customer to modify the text if they want to change the grammar or wording.

    The down sides are:

    It's slightly slower as it needs database connections, but a bit of smart caching can help.

    You'll have to write your own string retrieval code to perform the lookups, but I found it wasn't that bad.

    You have to write a UI that can cope with different sized strings. This is an issue in localisation generally, whether or not you use resx files or databases, but when customers find they can modify the display test, they can sometimes go overboard!


    Herbie

  • User profile image
    harumscarum

    Dr Herbie wrote:
    

    You have to write a UI that can cope with different sized strings. This is an issue in localisation generally, whether or not you use resx files or databases, but when customers find they can modify the display test, they can sometimes go overboard!



    I learned from the above that it is best to put labels above their form field. Damn Germans!

  • User profile image
    littleguru

    The best way is using the .resx files to do the localization. You can switch a form in Visual Studio to any given language and do the localization on it. For other strings, you should create the resx manually.

    Why to use the .resx approach? Well if you switch the languge of a form in Visual Studio you are able to resize and move the controls around.  Everything is stored in the resx. Which is very usable, because texts are longer in some languages than in others (German versus English).

  • User profile image
    littleguru

    harumscarum wrote:
    
    Dr Herbie wrote: 

    You have to write a UI that can cope with different sized strings. This is an issue in localisation generally, whether or not you use resx files or databases, but when customers find they can modify the display test, they can sometimes go overboard!



    I learned from the above that it is best to put labels above their form field. Damn Germans!



    Wazzup. Localize the forms with VS... move the labels and textboxes a little bit and you are good. How do you think does Microsoft handle all the languages Tongue Out

  • User profile image
    harumscarum

    littleguru wrote:
    The best way is using the .resx files to do the localization. You can switch a form in Visual Studio to any given language and do the localization on it. For other strings, you should create the resx manually.

    Why to use the .resx approach? Well if you switch the languge of a form in Visual Studio you are able to resize and move the controls around.  Everything is stored in the resx. Which is very usable, because texts are longer in some languages than in others (German versus English).


    A benefit of the db route is that any user can modify the text. This is helpful when you have people from all over the world doing the translations. I have never used a .resx file for translations so I am not sure how you would handle this.

  • User profile image
    littleguru

    harumscarum wrote:
    
    littleguru wrote: The best way is using the .resx files to do the localization. You can switch a form in Visual Studio to any given language and do the localization on it. For other strings, you should create the resx manually.

    Why to use the .resx approach? Well if you switch the languge of a form in Visual Studio you are able to resize and move the controls around.  Everything is stored in the resx. Which is very usable, because texts are longer in some languages than in others (German versus English).


    A benefit of the db route is that any user can modify the text. This is helpful when you have people from all over the world doing the translations. I have never used a .resx file for translations so I am not sure how you would handle this.


    There are well documented ways how to localize a form by using only and only the .resx files. I'm sure there are also editors out there that allow you to move controls on a form, based by the data coming from the .resx file.

    If you want a user to be able to modify parts of the UI's text, that part should go into the DB, but all the other should be done by using the .resx approach.

    Localizing has become a lot easier with .NET!

  • User profile image
    Massif

    Isn't a graphical resx editor included in the .Net framework? I can't remember what it would be called - but I remember a previous work thinking about using it for the translation teams to do the translation without bothering the developers.

    It didn't happen, and the name of the tool has slipped from my mind, ah well. (It didn't happen due to some combination of the IT department and the translators going "don't make me learn a new tool!")

    [edit: I must be thinking of WinRes]

  • User profile image
    Dr Herbie

    I did stumble onto this tool on Codeproject a while ago.  It might help take some of the sting out of translating resx files, but I wouldn't fully trust automatic language translation.

    Herbie

  • User profile image
    mYsZa

    .NET 2.0 comes with provider model, which makes dealing with problems like yours quite easy.
    If you don't want your resources stored in resx files (which isn't that bad idea), you can always write your own resource provider in place of the default GlobalResXResourceProvider / LocalResXResourceProvider.
    It is quite well explained in this article:
    http://msdn2.microsoft.com/en-us/library/aa905797.aspx

    Good luck! Big Smile

  • User profile image
    Gravy

    Thanks for all your input.

    I looked over the Vista localization methods recently and it appears to be the same as .NET 2 and win forms. The mechanics might be a bit different but at the end of the day you end up with resource dll's that contain the localized content. Is this what other people think.

    Does this mean that I don't have to worry too much about locaized text, it is something that can be done near then end of the dev cycle? (I know the code will have to be culture aware though).

    I presume when Orcas is released it will have some language setting on the xaml files and automatically generate resx like resource files.

     

  • User profile image
    Dr Herbie

    Gravy wrote:
    

    Does this mean that I don't have to worry too much about locaized text, it is something that can be done near then end of the dev cycle? (I know the code will have to be culture aware though).



    I would just go with a single language while developing and use FxCop (Code Analysis if you have TFS) globalisation rules to double check your culture awareness code.

    The quicker you have a second language to test with the better, though.  Finding mistakes earier is almost always less work Smiley
    In fact, you could use that CodeProject tool I mentioned earlier to create test localizations as you go.

    Herbie

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.