Are there any tools for generating a csv file for translations of a module? I.e. detecting calls to
__() within a module and outputting the information into a csv ready to be used as a translation file for the module?
You can use a simple* GREP of your template files:
> grep "__\(.*?\)" -Roh . | sed "s/__([\"']//" | sed "s/[\"'].*//g" | sort | uniq
This will output a list of unique phrases - such as (ran against
You have not tagged any products yet. You have placed no orders yet. You have placed no orders. You have placed no products yet.
This will get you 80% of the way there but now you'll need to do the following:
- This will return results for translations that are unquoted or are a direct translation of a variable, E.g.
$this->__($title)- these will need to be removed and handled manually.
You will need to copy this content into a second column, comma delimitted. I've gone to the trouble of adding the
sedcommand onto the grep above so that it outputs all in one go:
> grep "__\(.*?\)" -Roh . | sed "s/__([\"']//" | sed "s/[\"'].*//g" | sort | uniq | sed "s/\(.*\)/\"\1\",\"\1\"/"
* LOL this isn't terribly simple I guess
Here are some regular expressions that might help.
This should match
This should match
And for the XML files, just load the file as an xml object and then xpath the elements with the attribute
I've recently put together an extension that should identify the translatable texts in a module and generate the csv file for it. Check it out.
No answer but a suggestion if that's ok.
Trying to make good translations without seeing the context around that phrase or word will be extremely hard.
I suggest trying to find a basic translation set and then go from there. You can use the 'Inline translations' from the backend to see what parts in the webshop are translatable