grunt-contrib-translate

0.0.1 • Public • Published

grunt-contrib-translate Build Status

Translate dynamic text

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-contrib-translate

Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-contrib-translate');

Goal

Translator should be able to translate both static and dynamic text without requiring to know a single thing about programming. The translation solution should be scalable to all languages. A developer should be able to access the translates through a grunt command. There should be grunt command for update hashes from source and compile translation.

Problems

This can not be done today. The most popular translation standard is the gettext standard. It can deal with singular and plurals, but it gets more complicated on dynamic texts. It usually require a printf function, that inserts string into the translated text. Printf solution is not optimal since it is not part of Gettext. Also you can not update the hashes with the variables directly from source. With no variables available in the translation interface. It is quite hard to translate without contacting the developer.

Solution For Translators

A translator translates in grunt-contrib-translate by:

  • (1) Search a hash string in a Translation Interface
  • (2) Translate it and hit save

Solution For Developers

The translation function:

gt(TRANSLATION_HASH, JAVASCRIPT_OBJECT);

A developers workflow using grunt-translate:

  • (1) Use function gt() with a unique hash
  • (2) Update translation hashes from source
  • (3) Translates on the default language
  • (4) Compiles all the translations till ready to use in gt()

Storage files

en.json:

{
  'trin_hello_world': {
      vars : ['$property1', '$property2']
      translations: ['if', '$property1', '>', 'constant', 'Hello ${property1}'], ['elseif', '$property2', '>', 'Hello ${property1}'], ['else', 'Hello ${property1}']
  }
  ...
}
 

languages.json

{
  'en': 'english',
  'fr': 'french',
  ...
}

Documentation

(Coming soon)

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Release History

(Nothing yet)

License

Copyright (c) 2013 Tingan Ho Licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i grunt-contrib-translate

Weekly Downloads

1

Version

0.0.1

License

none

Last publish

Collaborators

  • tinganho