locked
Which better resource files or database RRS feed

  • Question

  • User-2116278700 posted

    Hi,

    I am working on a website which includes around 7 to 8 languages currently, this figure can be increased in near future. Kindly advise if I should use Resource files or database and whose performance will be better.

    Thanks and best regards,

    Faraz.

    Saturday, March 11, 2006 2:27 AM

All replies

  • User-2041805088 posted

    I'll take a database table over a resource file any day. As for performance: Processors are so fast these days that you would probably have to test the resource file and database to see which is faster for you situation.

    HTH,
    Ryan

    Saturday, March 11, 2006 2:36 AM
  • User-2116278700 posted

    hi ryan,

    thanks for ur urgent response. if perforance is not the issue then i think resource files for language coversion would be a better choice, otherwise i m not sure if i be able to achieve real globalization technique provided by .Net, rather than writing code to retrieve data from extranal resource i think resource file option is better. what do u say.

    thanks in advance.

    Faraz.

    Saturday, March 11, 2006 3:34 PM
  • User-2041805088 posted

    Assuming you're using .NET 2.0, you might want to take a look at this article:

    Localization Practices for .NET 2.0: It's Still About The Architecture

    HTH,
    Ryan

    Saturday, March 11, 2006 5:48 PM
  • User438956265 posted

    You have to consider maintenance of  Text also. I think that database is bettter option from maintenace point of view. Business Analyst can update the translation without the involvement of programmer.

    Sunday, March 12, 2006 11:49 AM
  • User-158764254 posted

    I started with resource files and found very early on that they were a nightmare to manage.

    did my german file include all the entries?
    were they translated?
    what about chinese?
    what about...french?  what about...

    i ended up putting all keys into sql with additional columns for each supported culture. now the administration is very easy and with a few queries, i can see where we are with regards to missing translations.

    as for utilizing those translations on the site, i load the set i need from sql on demand based on the users preferred culture.  each set is reasonably small so this doesnt present a performance penalty.  once a set is loaded, i cache it so it wont get reloaded every time the page is hit.

    if youd rather use the compiled resource files, you could still run a utility against the sql database to "create" the necessary data for the resource files.  this gives you the admin capabilities of a sql database while still allowing you to choose your localization mechanism.

    Sunday, March 12, 2006 2:25 PM
  • User1183903743 posted

    mbanavige,

    terrific and succinct commnet on the size of it!

    This is by far the most popular question in this forum.

    I started with resource files and found very early on that they were a nightmare to manage.

    If Microsoft had been bold enough to cut the resx editor from the suite and say: 'We do not provide a resx or translation tool(which is really the case). Get or build your own.', all would have been well.

    as for utilizing those translations on the site, i load the set i need from sql on demand based on the users preferred culture.  each set is reasonably small so this doesnt present a performance penalty.  once a set is loaded, i cache it so it wont get reloaded every time the page is hit.
    I'd add that in order not to have to rework the countless other goodies of asp.net that depend on or work with localization, it is best to wrap that translation db DAL into a custom resource provider, and get completely transparent drop-in replacement of the compiled resources mechanism.

    if youd rather use the compiled resource files, you could still run a utility against the sql database to "create" the necessary data for the resource files.  this gives you the admin capabilities of a sql database while still allowing you to choose your localization mechanism.
    I wrote a design time utility just like that. The resx schema is so simple, I wonder if its even worth publishing.

    There is one architecture advantage of this combined design-time db, runtime compiled approach. More overhead is in the app than the central db. Just drop them dlls in as many webservers as you want.

    All scenarios mentioned here use a db for management. They do not have to be at odds with each other though, as either-or. I am actually considering doing both:

    1.Run a site for a while with pure db localization. Easy to edit and tweak translations without recompiling. Keep some log of the edits.

    2.When that change log becomes pretty static, ie the site is pretty stable from translation point of view, no reason why you couldn't lock them in now.
    Run the utility to generate the resx from the db, build to compile them into .rersources and redeploy with sat assemblies.

     

     

    Sunday, March 12, 2006 3:59 PM
  • User-1639143169 posted
    i agree, db is muh easier to manage... as for perforamnce, you can always ggneerate your resoruce xmls on app start or soetjhing, and keep them cached... so the performance argument i think here is mute.
    then again... you could write a ui app... to easily manage resource files or database...
    and then, reosourfce files, have a nice point that they are easily removed and restored, or updated...you can send out a resource as is for transalation and swap back in... with a database you have to import export or use UI tool.... so i dont know... the choice is yours.. if you have an app that already uses one, i say it's not worh thte effor to change, unles you want to make a learning excersice out of it.
    Tuesday, March 14, 2006 7:52 PM
  • User1183903743 posted

    You cannot generate resources on app start. They have to be compiled. The IDE helps you do that by calling resgen.exe and al.exe behind the scenes. So it is not like aspx pages that may or may not be precompiled.

    However "or something" would work. Explicitly write out the xml in code and then compile the app prior to deplyment.

    Friday, March 17, 2006 3:28 PM
  • User686879743 posted

    Regarding localization in .NET 2.0 with resource files to go ahead with, did you find any tool to manage resource files for each country and for each page?

    Please let me know, I am in need of such approach with .NET2.0

     

    Thursday, March 30, 2006 11:22 AM
  • User-1639143169 posted

    Resoiurce files are per language culture... for example resource.en-us.resx etc....

    so that covers the cultures, any country should have a default cutlrure... so you shouldnt be worrying about that most likley.

    as for per page, you can have as many resource files are you want, but then you will have lots of repeated resources. if you make a global resoruce file for app, per lanugage, it will be sustantially easier to maintain, and likley you dont have millinoins of strings, so the memory footprint is mute point most likly.

     

     

    Thursday, March 30, 2006 12:26 PM