Skip to content

Instantly share code, notes, and snippets.

@0-Sony
Last active February 17, 2017 11:26
Show Gist options
  • Save 0-Sony/465e3659c180061a5e52 to your computer and use it in GitHub Desktop.
Save 0-Sony/465e3659c180061a5e52 to your computer and use it in GitHub Desktop.
Js translate. An Example to translate js into js file.
/** Build your Js **/
alert(Translator.translate('My Text to translate'));
alert(Translator.translate('Another Text to translate'));
<!-- Namespace/Module/etc/config.xml -->
<!-- Optional. Only if you want specify a csv file -->
<?xml version="1.0" encoding="utf-8"?>
<config>
<frontend>
<translate>
<modules>
<namespace_module>
<files>
<default>
Namespace_Module.csv
</default>
</files>
</namespace_module>
</modules>
</translate>
</frontend>
</config>
<!-- Namespace/Module/etc/jstranslator.xml -->
<?xml version="1.0" encoding="utf-8" ?>
<jstranslator>
<my-unique-id translate="message" module="namespace_module">
<message>My Text to translate</message>
</my-unique-id>
<another-unique-id translate="message" module="namespace_module">
<message>Another Text to translate</message>
</another-unique-id>
</jstranslator>
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2. in line 1.
/** app/local/fr_FR/Namespace_Module.csv **/
"My Text to translate","Mon texte à traduire"
"Another Text to translate","Un autre texte à traduire"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment