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: Wed, 28 Sep 2011 18:16:50 +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>
I really didn't want to get involved in this thread but yikes, guys, there *is* a better way. Martin G writes: > How would I set up a conditional for three or more possible > languages? Don't. 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? Generate the Javascript, too! The something-resembling-a-modern-language probably supports GNU gettext (if it doesn't, switch to Python), which in Python 2 would be used in a CGI script that looks like this: # I probably wouldn't do it this way in a real app, but I don't feel # like thinking about a real app right now. # start writhing def generate_javascript (): print "document.writeln(" # Watch for it, here it comes! print _("Hello.") # See it? Hint: it's just lying down; it's not dead. print ");" setlocale("ja") generate_javascript() # done writhing which you run through xgettext to get a file like this: # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR <EMAIL@example.com>, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-09-28 18:00+0900\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@example.com>\n" "Language-Team: LANGUAGE <LL@example.com>\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: js.py:4 msgid "Hello." msgstr "こんにちは。" A +----------------fill in dis here blank with language du jour and save as "$language.mo". There's more to it than that, of course, but basically unless you really are writing "hello world" and no more, for two languages and no more, the pain of maintaining translations is extremely high. gettext reduces it to a managable level. It's worth learning how to use it.
- Follow-Ups:
- Re: [tlug] Language localization in Javacript
- From: Lewske Wada
- 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
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Language localization in Javacript
- 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