- the whole file is stored in a single line
- non-ascii/accented characters are encoded in \uXXXX format
Could the translation files be stored in human-readable format?
Started by Robert Zelník, Jun 01 2012 03:07 AM
10 replies to this topic
#1
Posted 01 June 2012 - 03:07 AM
I really like the translation interface. I just have some difficulties with reading the output files exported from the ProcessWire Languages interface. Currently the .json files look like this:
#2
Posted 01 June 2012 - 03:51 AM
Why?
I've never had the feeling I need to edit them directly in the file.
Edit: Maybe something like this does help? http://www.jsoneditoronline.org/
Edit: Maybe something like this does help? http://www.jsoneditoronline.org/
@somartist | modules created | support me, flattr my work flattr.com
#3
Posted 01 June 2012 - 04:33 AM
You are right, we don't need to edit directly in the file, but the possibility to check the files can be useful for checking/comparing the changes, when more people collaborate on the translation etc.
The online JSON editor is great, thanks for the tip. I will use it.
The online JSON editor is great, thanks for the tip. I will use it.
#4
Posted 01 June 2012 - 05:22 AM
Ah. Then are you using the translation for frontend template? I tried it once and got away from it for various reasons. I still use translation files for frontend translation (for the static terms, forms etc) using yaml file for each langauge. So it's much easier to compare and have them in a readable key -> value format. It allows me to define them like:
Then in templates I can use it like:
In the head I include and determine the langauge using this code:
I use this php yaml parser lib https://github.com/fabpot/yaml
label_send: Send ...
Then in templates I can use it like:
$txt['label_send'];
In the head I include and determine the langauge using this code:
require_once($config->paths->root . "site/libs/yaml/sfYaml.php"); require_once($config->paths->root . "site/libs/yaml/sfYamlParser.php"); $yaml = new sfYamlParser(); // parse language file $txt = $yaml->parse(file_get_contents($config->paths->root . "site/languages/" . $lang . ".yaml"));
I use this php yaml parser lib https://github.com/fabpot/yaml
@somartist | modules created | support me, flattr my work flattr.com
#6
Posted 01 June 2012 - 07:03 AM
Why?
I've never had the feeling I need to edit them directly in the file.
I actually did. Why? First of all, I prefer working with larger amounts of text or code in my favourite text editor over working in a web frontend any time. Second, using search/replace mechanism would've made it much easier to keep the translation consistent. There are quite a number of phrases in the translateable files which are used two or more times. (Which, by the way, is a bit inefficient.)
I ended up not using my favourite editor (which can handle .json files) because the language .json files are minified and apparently use some kind of escaping for special characters (like German umlauts). I didn't want to risk losing work over some weird side effects of using an editor.
#7
Posted 01 June 2012 - 07:43 AM
Yeah, maybe it's not as ideal as one may wish it to be to enter translations. But it's pretty decent start. As I understand it, it's using gettext and it uses textdomain for each file/module in the context of it. This may seem inefficent, but one global file for all words used all over the system would be a nightmare. One phrase used in the context of a module may be differently translated in the context of another module in another language. Note also context information (descr) can be added right after the translation syntax, that will show in the translation editor. I think it's well thought out by Ryan, even though there's always things to improve. Maybe he also pops in to give his statement.
@somartist | modules created | support me, flattr my work flattr.com
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













