Cette extension n’a pas été testée avec plus de trois mises à jour majeures de WordPress. Elle peut ne plus être maintenue ou supportée et peut avoir des problèmes de compatibilité lorsqu’elle est utilisée avec des versions de WordPress plus récentes.

Localize js

Description

WordPress has the function wp_localize_scripts for translation, but the strings passed to it have to be hard-coded. Until you parse the .js-files and scan for occurrences of _e() with a fast regexp, and localize them with the data using the WordPress _e-function to localize from a .po file. *Note*. Your po-file has to include strings from javascript files. To do this in Poedit, see http://stackoverflow.com/questions/16557327/how-to-generate-po-file-from-js-file-using-poedit.

Installation

  1. Unzip the plugin in your plugin directory.
  2. Activate the plugin in WordPress.
  3. Make sure your .po-file is in your /languages directory and contains the translations from the .js-files.
  4. Place the following code in your javascript file:
function _e(s) {     return ccb_e_ccb_HANDLE[s]; } 

where you replace HANDLE with the handle for your script (you use the handle to enqueue the script in functions.php.) 5. Translate your javascripts! You can now use alert ( _e("Error! Try again in your language")). Note that there is no text-domain here as that is taken care of by PHP when it fills the array dynamically.

FAQ

None for the moment.

Avis

Il n’y a aucun avis pour cette extension.

Contributeurs/contributrices & développeurs/développeuses

« Localize js » est un logiciel libre. Les personnes suivantes ont contribué à cette extension.

Contributeurs

Traduisez « Localize js » dans votre langue.

Le développement vous intéresse ?

Parcourir le code, consulter le SVN dépôt, ou s’inscrire au journal de développement par RSS.

Journal des modifications

December 11, 2014

  • First release.