locked
Localization using database RRS feed

  • Question

  • User-189004138 posted

    Hi

    I am making an web application using Asp.Net MVC 4.And as an requirement I have to use Localization.

    I want to make localization using database insted of resource file.

    Can you please help me how can i do it best way to achive localization using database

    Thanks

    Monday, June 3, 2013 1:40 AM

Answers

  • User-257383369 posted

    Follow the thread

    http://forums.asp.net/t/1625825.aspx/1

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 4, 2013 1:08 AM

All replies

  • User1266497125 posted

    If you want to follow along the MVC approach then you need to implement DataAnnotation attribute that can connect to the database and retrieve the value for a specific key. The best approach would be to subclass DisplayAttribute and work from that point on. However, one problem that you would have is too many hits on your database. My suggestion to you would be to use Resource files and learn how to work with satellite assemblies. This is a much better and cleaner solution.

    Monday, June 3, 2013 3:09 AM
  • User-189004138 posted

    Thanks for your reply.

    I have an requirement to use Database.Can you please give me an some good referance so i can exploer more and gone through the right solution

    I need to explain the reason why database approach is not good.

    Monday, June 3, 2013 3:39 AM
  • User1454091963 posted

    You can use database approach - it's more flexible and easier.

    To improve the performance you can use a global cache. All resources have a key and locale. If the resource is not found in the cache then you fetch it from database and store it in cache so next time when you need the same resource you won't need to query the database.

    Monday, June 3, 2013 7:12 AM
  • User-189004138 posted

    Wang - Can you please give me the referance or some basic code so i can move into that direction

    Thanks

    Monday, June 3, 2013 7:14 AM
  • User1946108874 posted

    What you could do is store all the resource in a table in the database for each culcture. For Example if your page has a button and the caption/text you want to dsiplay when the culcture is english is 'GO' and the table structure shoould be like this 

    LocaleId

    Resource Key

    Resource Value

    1033

    FRNT_GO

    GO

    1041

    FRNT_GO

    行く

    You can get all these resource based on the localeId and store it in the cache when the first time application starts, similar way you store all your messages also in a similar manner but in the long run it would be diffcult to maintain.

    
    



    Monday, June 3, 2013 10:46 AM
  • User-189004138 posted

    Hello

    Can you please give me a some sample so i can start on that way

    Thanks

    Tuesday, June 4, 2013 12:50 AM
  • User-257383369 posted

    Follow the thread

    http://forums.asp.net/t/1625825.aspx/1

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 4, 2013 1:08 AM