Best-practices for localizing a SQL Server (2005/2008) database

后端 未结 10 1249
执笔经年
执笔经年 2020-12-13 11:09

Question

I\'m sure many of you have been faced by the challenge of localizing a database backend to an application. If you\'ve not then I\'d be pretty confident in

10条回答
  •  感情败类
    2020-12-13 11:34

    I think you can stick with XML which allows for a cleaner design. I would go further and take advantage of the xml:lang attribute which is designed for this usage :

    
      Detta är ett namn
      This is a name
    
    

    One step further, you could select the localized resource in your query via a XPath query (as suggested in the comments) to avoid any client side treatment. This would give something like this (untested) :

    SELECT Name.value('(l10n/text[lang()="en"])[1]', 'NVARCHAR(MAX)')
      FROM Product
      WHERE Product.ID=10;
    

    Note that this solution would be an elegant but less efficient solution than the separate table one. Which may be OK for some application.

提交回复
热议问题