title: How to localise static website text from translations stored in a database?
body: <p>I need to design a translation mechanism/strategy for the static text in my (scalable) web applications - which are based on HTML, JQuery/JavaScript in an ASP.NET environment (but no server side controls) with dynamic data loaded from asynchronous jQuery calls to http handlers.</p>
  
  <p>I have successfully localised numbers, dates, etc using <a href="https://github.com/jquery/globalize" rel="nofollow noreferrer">Globalize</a>, however now need to sort out the text translation.</p>
  
  <p>Translated text is stored appropriately in a database (maintained by native partners in another application), therefore, I do not want to use a file based <a href="http://msdn.microsoft.com/en-us/library/ms227427.aspx" rel="nofollow noreferrer">ResX</a> equivalent, like <a href="http://keith-wood.name/localisation.html" rel="nofollow noreferrer">jQuery Localisation</a>/<a href="https://github.com/coderifous/jquery-localize" rel="nofollow noreferrer">jQuery Localize</a>/<a href="http://code.google.com/p/jquery-i18n-properties/" rel="nofollow noreferrer">jQuery-i18n-properties</a> approaches, instead I am after a solution similar to <a href="http://msdn.microsoft.com/en-us/library/aa905797.aspx" rel="nofollow noreferrer">extending the Resource-Provider Model</a> that localises ASP.NET controls (which I don't have), to get the translation from the database.</p>
  
  <p><strong>Client Side Approach</strong>: I just stumbled across <a href="http://jamuhl.github.com/i18next/#n15" rel="nofollow noreferrer">i18next's dynamic (non-static) resouce route</a> and am trying to work out if I can return something like that from a http handler (and caching in <a href="http://www.jstorage.info/" rel="nofollow noreferrer">JStorage</a>/<a href="http://brian.io/lawnchair/" rel="nofollow noreferrer">LawnChair</a>) to fill in place-holders/tags using <a href="http://jamuhl.github.com/i18next/#n4" rel="nofollow noreferrer">the jQuery function</a> or take a similar approach with <a href="http://mustache.github.com/" rel="nofollow noreferrer">Moustache</a> or <a href="http://twitter.github.com/hogan.js/" rel="nofollow noreferrer">hogan.js</a> templates.</p>
  
  <p><strong>Server Side Approach:</strong>
  Modify the HTML before it is served, for example <a href="https://stackoverflow.com/a/1695021/198048">this answer</a> suggests using the <a href="http://msdn.microsoft.com/en-us/library/system.web.httpresponse.filter.aspx#Y300" rel="nofollow noreferrer">HttpResponse.Filter</a> to modify the response server side (see <a href="https://web.archive.org/web/20211029043851/https://www.4guysfromrolla.com/articles/120308-1.aspx" rel="nofollow noreferrer">this article</a>). As the buffer is chunked, I'd have to capture the entire stream as suggested <a href="http://www.west-wind.com/weblog/posts/2009/Nov/13/Capturing-and-Transforming-ASPNET-Output-with-ResponseFilter" rel="nofollow noreferrer">here</a>, which does lead to a performance hit, however, I hope I can mitigate this by <a href="http://msdn.microsoft.com/en-us/library/xadzbzd6.aspx" rel="nofollow noreferrer">caching each (language) version</a> of the page.</p>
  
  <p>Or use HTTP Handlers <a href="http://www.west-wind.com/weblog/posts/2009/Apr/02/A-Localization-Handler-to-serve-ASPNET-Resources-to-JavaScript" rel="nofollow noreferrer">like this</a> looks like simpler approach, though I am less sure how to cache multiple versions of the page in this instance.</p>
  
  <p>Does anyone else have experience with these approaches or know of anything similar or 'best practices' that meets the requirements especially in terms of performance, scalability and maintainability?</p>
  
  <p><em>If anything isn't clear, please let me know, I am new to web development. :)</em></p>
  
  <p>Note: This is for web applications running on tablets/hand-held devices for data capture, it isn't a CMS or static site (the previous incarnation used to run on the .Net Compact Framework, for about 5 years and it's time for an update so users can use non-windows devices such as android and IPad).</p>