Title: Localize js
Author: kamiel79
Published: <strong>2014 年 12 月 11 日</strong>
Last modified: 2014 年 12 月 11 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://ps.w.org/localize-js/assets/icon-128x128.png?rev=1042825)

# Localize js

 作者：[kamiel79](https://profiles.wordpress.org/kamiel79/)

[下载](https://downloads.wordpress.org/plugin/localize-js.zip)

 * [详情](https://cn.wordpress.org/plugins/localize-js/#description)
 * [评价](https://cn.wordpress.org/plugins/localize-js/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/localize-js/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/localize-js/#developers)

 [支持](https://wordpress.org/support/plugin/localize-js/)

## 描述

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.

## 安装

 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.

## 常见问题

None for the moment.

## 评价

此插件暂无评价。

## 贡献者及开发者

「Localize js」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ kamiel79 ](https://profiles.wordpress.org/kamiel79/)

[帮助将「Localize js」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/localize-js)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/localize-js/)，查看[SVN仓库](https://plugins.svn.wordpress.org/localize-js/)，
或通过[RSS](https://plugins.trac.wordpress.org/log/localize-js/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/localize-js/)。

## 更新日志

#### December 11, 2014

 * First release.

## 额外信息

 *  版本 **1.0**
 *  最后更新：**12 年前**
 *  活跃安装数量 **不到10**
 *  WordPress 版本 ** 3.0 或更高版本 **
 *  已测试的最高版本为 **4.01**
 *  语言
 * [English (US)](https://wordpress.org/plugins/localize-js/)
 * 标签
 * [i18n](https://cn.wordpress.org/plugins/tags/i18n/)[javascript](https://cn.wordpress.org/plugins/tags/javascript/)
   [l10n](https://cn.wordpress.org/plugins/tags/l10n/)[multilingual](https://cn.wordpress.org/plugins/tags/multilingual/)
   [po](https://cn.wordpress.org/plugins/tags/po/)[translation](https://cn.wordpress.org/plugins/tags/translation/)
   [wordpress.org](https://cn.wordpress.org/plugins/tags/wordpress-org/)
 *  [高级视图](https://cn.wordpress.org/plugins/localize-js/advanced/)

## 评级

尚未提交反馈。

[您的评价](https://wordpress.org/support/plugin/localize-js/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/localize-js/reviews/)

## 贡献者

 *   [ kamiel79 ](https://profiles.wordpress.org/kamiel79/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/localize-js/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](http://code.creativechoice.org/localize-js/)