Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Language localization in Javacript
- Date: Thu, 29 Sep 2011 15:52:19 +0900
- From: "Stephen J. Turnbull" <stephen@example.com>
- Subject: Re: [tlug] Language localization in Javacript
- References: <CA+kCxRb8df237PV1ZdvOp5Emuqgz_=RdVzpa_fPMJEbQZRX3sA@example.com> <4E81AF97.2060001@example.com> <CA+kCxRaM==wbOGH4Qcs__qsPY9SEyQNH9OBefxDbHv0Y2MQ6YQ@example.com> <87ty7xgh6l.fsf@example.com> <CA+kCxRYmTizivHp+gaK69R-pjFMLmuW-ADetEKsb2Lxn4MtvTg@example.com>
Martin G writes: > > Surely your Javascript is hosted on something resembling a > > server with something sorta like a modern language being used to > > generate something more or less substitutable for well-styled HTML as > > well as serving the Javascript and other content, right? > > Nope. > > It's a self contained application that one downloads, and it only ever > communicates with a server by getting some JSON data now and again. So what? These are hard-coded strings either way. If you generate the appropriate Javascript on the fly, what will happen is that the user will download a *localized* self-contained application, which will then proceed to get some JSON data now and again. All that happens with this approach is that people don't download strings they don't need. OK, so if you've got somebody using an iPad that they share with somebody who prefers a different language, they might prefer an *internationalized* self-contained application with downloadable language packs. Even a three-toed treefrog has enough fingers on one hand to count the number of people who share their PIM with somebody who prefers a different language (at least in this country; in theory people might share PIMs in rural Bangladesh, I suppose). And if you *really do* need the language packs .... Eg, if the application is actually a dictionary or translation tool, you can still use this approach with gettext by switching languages in the generating process at appropriate times. You might end up by generating the switch statements: languages = ['en', 'de', 'fr', 'es', 'pt', 'ru', 'ja'] def generate_javascript(): print 'switch (navigator.language.substr(0, 2)) {' for lang in languages: setlocale(lang) # Here's what tells Python which # translation you want. print ' case "%s" :' % lang print ' document.writeln ("%s");' % _('Hello.') print ' break;' print '}' Can we spell "scalability," children? Excellent! I knew you could! You can also, for example, allow the user to select only the languages they want by treating 'languages' as a user variable rather than a constant. (I can't think of a real application for that off hand in this day and age of 32GB memory sticks, but hey maybe you're distributing the Encyclopedia Takokusekika ....)
- Follow-Ups:
- Re: [tlug] Language localization in Javacript
- From: Martin G
- References:
- [tlug] Language localization in Javacript
- From: Martin G
- Re: [tlug] Language localization in Javacript
- From: Darren Cook
- Re: [tlug] Language localization in Javacript
- From: Martin G
- Re: [tlug] Language localization in Javacript
- From: Stephen J. Turnbull
- Re: [tlug] Language localization in Javacript
- From: Martin G
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Language localization in Javacript [SOLVED]
- Next by Date: Re: [tlug] Language localization in Javacript
- Previous by thread: Re: [tlug] Language localization in Javacript
- Next by thread: Re: [tlug] Language localization in Javacript
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links