i18n - string in javasciprt

3 views
Skip to first unread message

Claudia Jürgen

unread,
Nov 3, 2011, 10:35:17 AM11/3/11
to bibap...@googlegroups.com
Hello Howard,

after a long (national holdiay) weekend, back to testing.

There is another corner, where strings are injected from:
[bibapp]/public/javascripts
e.g.
[bibapp]/public/javascripts/application.js
[bibapp]/public/javascripts/specific/contributorships/index.js
[bibapp]/public/javascripts/specific/imports/show.js
[bibapp]/public/javascripts/specific/keywords/timeline.js
[bibapp]/public/javascripts/specific/memberships/new.js


Have nice day

Claudia


--
Claudia Juergen
Universitaetsbibliothek Dortmund
Eldorado
0231/755-4043
https://eldorado.tu-dortmund.de/

Howard Ding

unread,
Nov 3, 2011, 12:30:56 PM11/3/11
to bibap...@googlegroups.com
It should be fairly easy to fix these, mostly a matter of finding a good
jquery i18n plugin.

Howard

Howard Ding

unread,
Nov 3, 2011, 1:58:16 PM11/3/11
to bibap...@googlegroups.com
There's a plugin called jsperanto that looks the most promising of those
that I've examined. I'm starting to incorporate it for the appropriate
javascript translations (things like the datatables plugin that have
their own i18n scheme won't need it). Assuming that things continue to
look okay I'll write up how it works on the Wiki later. In brief there
will be JSON files in public/javascripts/translations that it consults
to do the translations. Things like pluralization and interpolation are
possible. Though some of the syntax is different than Rails i18n, it is
similar in spirit.

Howard

On 11/3/2011 9:35 AM, Claudia J�rgen wrote:

Howard Ding

unread,
Nov 3, 2011, 2:06:13 PM11/3/11
to bibap...@googlegroups.com
One further note: I also have in mind the possibility to include these
translations as a separate section in the regular
config/locales/<locale>.yml file and automatically generate the JSON
files in public/javascripts/translations from that (e.g. on application
start up).

The disadvantages would be that this would be a special section in that
file and translators would have to remember to use the appropriate
interpolation syntax here (or for Tolk I'd need to modify a bit so it'd
be obvious when that syntax was needed).

The advantages would be that it is (IMHO) a lot easier when working by
hand to write YAML than JSON, there wouldn't be yet one more place to do
translations, and the existing tools (perhaps with a bit of
modification, e.g. for Tolk) would be able to detect missing/changed
keys, etc.

Opinions?

Howard

On 11/3/2011 9:35 AM, Claudia J�rgen wrote:

hading2

unread,
Nov 3, 2011, 5:18:10 PM11/3/11
to bibapp-dev
After thinking it through a bit I just went ahead and did this, as it
seemed considerably simpler to me.

In the <locale>.yml there is a jsperanto section. All of these should
be translated with the Jsperanto interpolation syntax (e.g. "You have
__count__ items"). When the application starts up it parses this
section for each available_locale and writes it as JSON to the correct
place for the jsperanto library to find it.

I'll document on the wiki.

Howard

Claudia Jürgen

unread,
Nov 4, 2011, 3:55:54 AM11/4/11
to bibap...@googlegroups.com
Hi all,

seems reasonable, I'll update the de.yml.

Thanx

Claudia

--

Reply all
Reply to author
Forward
0 new messages