Re: Question related to Recommendation/Best Practice/Relevant Discussions for "Translation-relevant content related to 'script' element in HTML"

On 20.8.2013 11:25, Arle Lommel wrote:

> This seems like a particularly elegant approach to handling this issue. And it one wanted to you could essentially combine it with Christian’s method to store multiple localizations by simply having ID values like "PLEASE_WAIT-de" where a modest processing layer updates the ID by looking at the locale to pull the appropriate piece of content.

There is even more elegant and proper approach, use lang attribute:

<script id="PLEASE_WAIT" lang="en" type="text/plain"
translate="yes">Please <em>wait</em> ...</script>

<script id="PLEASE_WAIT" lang="de" type="text/plain"
translate="yes">Bitte <em>warten</em> ...</script>

and then use

document.querySelector("#PLEASE_WAIT:lang(en)")
and
document.querySelector("#PLEASE_WAIT:lang(de)")

for accessing respective localizations. Of course selector can be
composed dynamically based on the current language:

document.querySelector("#PLEASE_WAIT:lang(" + currentLang + ")")

    Jirka

-- 
------------------------------------------------------------------
  Jirka Kosek      e-mail: jirka@kosek.cz      http://xmlguru.cz
------------------------------------------------------------------
       Professional XML consulting and training services
  DocBook customization, custom XSLT/XSL-FO document processing
------------------------------------------------------------------
 OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
------------------------------------------------------------------
    Bringing you XML Prague conference    http://xmlprague.cz
------------------------------------------------------------------

Received on Tuesday, 20 August 2013 10:30:24 UTC