{"id":33219,"date":"2014-12-11T17:29:20","date_gmt":"2014-12-11T17:29:20","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/localize-js\/"},"modified":"2014-12-11T17:33:35","modified_gmt":"2014-12-11T17:33:35","slug":"localize-js","status":"publish","type":"plugin","link":"https:\/\/fr.wordpress.org\/plugins\/localize-js\/","author":11326224,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0","stable_tag":"trunk","tested":"4.01","requires":"3.0","requires_php":"","requires_plugins":"","header_name":"Localize JS","header_author":"Kamiel Choi","header_description":"","assets_banners_color":"","last_updated":"2014-12-11 17:33:35","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/code.creativechoice.org\/localize-js\/","header_plugin_uri":"http:\/\/code.creativechoice.org\/","header_author_uri":"http:\/\/creativechoice.org","rating":0,"author_block_rating":0,"active_installs":0,"downloads":1306,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":"1042825","resolution":"128x128","location":"assets","width":128,"height":128}},"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[104,229,1984,99,2344,2333,4894],"plugin_category":[48,59],"plugin_contributors":[],"plugin_business_model":[],"class_list":["post-33219","plugin","type-plugin","status-publish","hentry","plugin_tags-i18n","plugin_tags-javascript","plugin_tags-l10n","plugin_tags-multilingual","plugin_tags-po","plugin_tags-translation","plugin_tags-wordpress-org","plugin_category-language-tools","plugin_category-utilities-and-tools","plugin_committers-kamiel79"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/localize-js\/assets\/icon-128x128.png?rev=1042825","icon_2x":false,"generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>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.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Unzip the plugin in your plugin directory. <\/li>\n<li>Activate the plugin in Wordpress.<\/li>\n<li>Make sure your .po-file is in your \/languages directory and contains the translations from the .js-files.<\/li>\n<li>Place the following code in your javascript file: <\/li>\n<\/ol>\n <pre>function _e(s) {     return ccb_e_ccb_HANDLE[s]; } <\/pre>\n <p>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 <code>alert ( _e(\"Error! Try again in your language\"))<\/code>. Note that there is no text-domain here as that is taken care of by PHP when it fills the array dynamically.<\/p>\n\n<!--section=faq-->\n<p>None for the moment.<\/p>\n\n<!--section=changelog-->\n<h4>December 11, 2014<\/h4>\n <ul>\n<li>First release.<\/li>\n<\/ul>","raw_excerpt":"Provide translation function _e(&quot;&quot;) in javascript files.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/33219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=33219"}],"author":[{"embeddable":true,"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/kamiel79"}],"wp:attachment":[{"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=33219"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=33219"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=33219"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=33219"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=33219"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/fr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=33219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}