定制 yoast/i18n-module 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yoast/i18n-module

最新稳定版本:3.1.1

Composer 安装命令:

composer require yoast/i18n-module

包简介

Handle i18n for WordPress plugins.

关键字:

README 文档

README

CS Lint Code Climate

⚠️ Update September 28th 2023 ⚠️

We have discontinued development on this project. If you're interested in this module, we happily refer you to a well-maintained fork by @mte90 at https://github.com/WPBP/i18n-notice.

Yoast i18n module

Promote your own translation site for people who are using your plugin in another language than en_US.

Example of the rendered promo box

Example promo box 1

Example promo box 2

The image, the name of your plugin and the name of your translation project are all configurable (see example below). The name of the language is retrieved from your GlotPress install, as is the percentage translated. The box doesn't display when a language has been translated for 90% or more.

How to use this module

Include it in your project using composer:

composer require yoast/i18n-module

Alternatively you can include the library as a submodule. Make sure the class is loaded and instantiate it like this:

new Yoast_I18n_v3( array( 'textdomain' => '{your text domain}', 'project_slug' => '{your probject slug}', 'plugin_name' => '{your plugin name}', 'hook' => '{the hook to display the message box on}', 'glotpress_url' => '{url to your glotpress installation; http://translate.yoast.com}', 'glotpress_name' => '{name of your glotpress installation}', 'glotpress_logo' => '{url to a logo which will be shown}', 'register_url ' => '{url to use when registering for a project}', ) );

If the service you are using doesn't follow the GlotPress conventions for the URLs, you may want to pass directly the full api_url to get the list of available translations, instead of letting the class build it from glotpress_url:

new Yoast_I18n_v3( array( 'textdomain' => '{your text domain}', 'project_slug' => '{your probject slug}', 'plugin_name' => '{your plugin name}', 'hook' => '{the hook to display the message box on}', 'api_url' => '{url the JSON list of the available languages}', 'glotpress_name' => '{name of your glotpress installation}', 'glotpress_logo' => '{url to a logo which will be shown}', 'register_url ' => '{url to use when registering for a project}', ) );

Because translate.wordpress.org is also a GlotPress installation you can use the i18n-module to promote translation your plugin on there. To do this you can use the dedicated wordpress.org class:

new Yoast_I18n_WordPressOrg_v3( array( 'textdomain' => '{your text domain}', 'plugin_name' => '{your plugin name}', 'hook' => '{hook to display the message box on}', ) );

Customize where and when to render the message

Since 3.0.0 you can also decide to render the message in a message-box of your own, just provide the second argument to the constructor as false to disable the showing of the box by the module itself.

$i18n_module = new Yoast_I18n_v3( array( 'textdomain' => '{your text domain}', 'project_slug' => '{your probject slug}', 'plugin_name' => '{your plugin name}', 'hook' => '{the hook to display the message on - not used in this example}', 'glotpress_url' => '{url to your glotpress installation; http://translate.yoast.com}', 'glotpress_name' => '{name of your glotpress installation}', 'glotpress_logo' => '{url to a logo which will be shown}', 'register_url ' => '{url to use when registering for a project}', ), false ); $message = $i18n_module->get_promo_message();
$i18n_module = new Yoast_I18n_WordPressOrg_v3( array( 'textdomain' => '{your text domain}', 'plugin_name' => '{your plugin name}', 'hook' => '{hook to display the message on - not used in this example}', ), false ); $message = $i18n_module->get_promo_message();

yoast/i18n-module 适用场景与选型建议

yoast/i18n-module 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.22M 次下载、GitHub Stars 达 22, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「wordpress」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 yoast/i18n-module 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 yoast/i18n-module 我们能提供哪些服务?
定制开发 / 二次开发

基于 yoast/i18n-module 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.22M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 22
  • 点击次数: 23
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 18
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-01-04