You are here: Foswiki>Tasks Web>Item4992 (31 Jan 2018, MichaelDaum)Edit Attach

Item4992: Work out how to translate Javascript strings.

pencil
Priority: Enhancement
Current State: Closed
Released In: 2.1.1
Target Release: patch
Applies To: Engine
Component: I18N, JQueryPlugin, JavaScript
Branches: master Item13897 Release02x01 Item14033 Item14380 Item14537
Reported By: TWiki:Main.CrawfordCurrie
Waiting For:
Last Change By: MichaelDaum
Javascript often contains strings; some javascript - such as TinyMCE - even has a whole architecture dedicated to supporting translation of those strings. But they all fly under the radar of our current string translations process.

There needs to be a way to add Javascript to the string translations - and without requiring a total rewrite of the code!

-- TWiki:Main/CrawfordCurrie - 19 Nov 2007

In foswiki.pattern.tmpl I am using the meta tag for this:
<meta name="TOPIC" content="%INTURLENCODE{%TOPIC%}%" />
<meta name="WEB" content="%INTURLENCODE{%WEB%}%" />
<meta name="SCRIPTURLPATH" content="%SCRIPTURLPATH%" />
<meta name="SCRIPTSUFFIX" content="%SCRIPTSUFFIX%" />
<meta name="TEXT_JUMP" content="%MAKETEXT{"Jump"}%" />
<meta name="TEXT_SEARCH" content="%MAKETEXT{"Search"}%" />
<meta name="TEXT_NUM_TOPICS" content="%MAKETEXT{"Number of topics:"}%" />
<meta name="TEXT_MODIFY_SEARCH" content="%MAKETEXT{"Modify search"}%" />

This can become very lengthy if all js strings are written this way.

-- ArthurClemens - 17 Dec 2008

I have also seen problems with the meta tag on some older browsers. IE6, for example, sometimes loses the relation between the HEAD and the META tags so that getElementsByTagName doesn't find them frown, sad smile

It would be quite neat to be able to expand MAKETEXT in JS at load time i.e. on the server. That way you avoid downloading large "language packs" to the browser. Alternatively we could adopt the language pack approach used by TinyMCE.

-- CrawfordCurrie - 18 Dec 2008

Next version of JQueryPlugin comes with a simple and easy-to-use i18n module to translate strings in javascript.

-- MichaelDaum - 18 Feb 2016

How do the JQueryPlugin strings plug into either translation toolkit, or weblate? If we are adding a new translation engine, it really needs to fit into our current infrastructure somehow. Weblate via translatetoolkit does have some support for JSON strings, but I have no idea how it works.

IMHO this needs a feature proposal and review current translators if it doesn't fit in our current translation architecture.

-- GeorgeClark - 23 Feb 2016

Weblate is just fine. It only needs a separate "component" (that's what weblate calls it) that points to pub/System/SomePlugin/i18n/*.js files in addition to the gettext po files. We will have projects with both kinds of components for po and json, e.g. ListyPlugin. NatEditPlugin will follow. Big one is ConfigurePlugin ... if we choose to translate its interface. At least that's possible right now.

Usage of the new i18n component is well documented.

Yay, took us only 9 years to close this bug item.

-- MichaelDaum - 25 Feb 2016
 
Topic revision: r19 - 31 Jan 2018, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy