Is this a bad idea then?
On Jun 1, 12:44 pm, Adam Groves <[EMAIL PROTECTED]> wrote:
> I'd be grateful for feedback regarding the following:
>
> /* Iterate over elements and lookup translation for language in JSON
> dictionary */
> function translateChildren(parent, language) {
>
> var phrases = parent.getElementsByClassName('lang');
>
> phrases.each(function(p) {
> var phrase = p.readAttribute('for');
> p.innerHTML = translations[phrase][language];
> });
>
> }
>
> /* Get language from Cookie */
> function getLanguage() {
> document.cookie.scan(/language=(..)/,
> function(match){
> lang = match[1]
> })
> return lang;
>
> }
>
> /* JSON dictionary */
> var translations = {
> 'search': {'en': "Search", 'de': "Suche"},
> 'logout': {'en': "Logout", 'de': "Abmelden"},
> 'account': {'en': "Account", 'de': "Konto"}
>
> }
>
> ...
> <div id="menu">
> <a href = "" class = "lang" for = "search">Search</a>
> <a href = "" class = "lang" for = "account">Account</a>
> <a href = "" class = "lang" for = "logout">logout</a>
> </div>
> <script>translateChildren($('menu'), getLanguage())</script>
> ...
>
> The inline script tag is a bit messy, but means the page can be
> translated before the onload event would trigger it.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---