View Single Post
Old 01-02-2012, 08:22 AM   #60
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by ixtab View Post
There's one final issue that I'm having with the JS part: the format that is used is relatively standard, but it's still executable JS which transifex can't make sense of. Would "ripping out" the strings into a .properties file make sense, so that they can be translated using the normal method? Or do you see an alternative? (short of simply editing the JS files directly).
I thought about the same method (extracting strings from JS files into .properties).

One note: this properties should be uploaded to transifex with type MOZILLAPROPERTIES. Format of Mozilla .properties is same as Java .properties, but in Mozilla .properties non-ASCII values are stored as UTF-8 strings, not as Unicode-escaped sequences. It's more friendly for reader of .properties.

I've commited POC of tool for extracting JS strings. For now, it's just searching for strings in given file and dumps internal representation of found strings. Each found string is represented as tuple:

Code:
(<id of string>, <value of string>, <starting position of string in JS file>, <ending position of string in JS file>)
(Tool is not commented [yet], sorry.)

With this information it could be possible to convert JS file into two: JS template and .properties, like:

Code:
// strings.js
var a = 'a';
var b = {
  x = 'x';
  y = 'y'
};
Code:
// strings.template.js
var a = '{{a}}';
var b = {
  x = '{{b.x}}';
  y = '{{b.y}}'
}
Code:
# strings.properties
a=a
b.x=x
b.y=y
Then translation of strings.properties could be parsed and values could be applied to template resulting in translated strings.js.

What do you think about it?
eureka is offline   Reply With Quote