定制 wppack/translations-installer 二次开发

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

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

wppack/translations-installer

Composer 安装命令:

composer require wppack/translations-installer

包简介

Composer plugin that downloads WordPress core, plugin and theme translations from wordpress.org as packages are installed or updated.

README 文档

README

CI License: GPL-2.0-or-later PHP Version

日本語版 README

Composer plugin that downloads translation files for WordPress core, plugins and themes from wordpress.org, as the packages are installed or updated.

A fork of bjornjohansen/wplang, brought into the WPPack package family.

Supports Composer v2 only. Requires PHP 8.2+ and ext-zip.

Installation

Add the configuration to composer.json (paths are relative to the project root, i.e. the directory holding composer.json):

{
    "extra": {
        "wordpress-translations": ["ja", "fr_FR"],
        "wordpress-translations-dir": "web/wp-content/languages"
    }
}

Then:

$ composer require wppack/translations-installer

Composer asks to trust the plugin on first install; allow it (or pre-seed config.allow-plugins):

{
    "config": {
        "allow-plugins": {
            "wppack/translations-installer": true
        }
    }
}

Usage

Nothing to run: whenever a package of type wordpress-core, wordpress-plugin or wordpress-theme is installed or updated, the matching language packs are fetched from the wordpress.org translations API and unpacked into the configured directory — core at its root, plugins and themes under plugins/ and themes/, the same layout WordPress itself uses under wp-content/languages.

The core package is not tied to roots/wordpress: any package that declares "type": "wordpress-core" (e.g. roots/wordpress, johnpbloch/wordpress-core) is picked up. Core translations are looked up on wordpress.org by version only, so the package name does not matter.

Packages that have no translations for the configured locales print a note and are skipped; the install itself never fails because of translations.

Commands

Language packs on wordpress.org are often updated after a package release, so the plugin also ships two commands that can be run at any time:

$ composer translations:update

Downloads translations for every installed WordPress package. Only locales that are missing locally or outdated on wordpress.org are fetched; current ones are skipped. Failures are reported per package and never fail the command.

$ composer translations:status

Read-only report of every package × locale: Up to date, Outdated (local and remote timestamps shown), Missing or Not available. Exits with code 1 when anything can be updated, so it doubles as a CI freshness check:

$ composer translations:status
wpackagist-plugin/query-monitor
  - ja     Up to date (2026-07-03 14:02:39)
  - fr_FR  Outdated   (local 2026-01-15 10:00:00 → remote 2026-06-20 09:14:31)
All translations are up to date.

How freshness is decided

The wordpress.org API reports an updated timestamp per language pack; the installed .po file carries the same timestamp in its PO-Revision-Date header. The plugin compares the two — the same mechanism WordPress core uses for its own language pack updates. There is no state file: the installed files are the record, so deleting a .po simply causes that locale to be re-downloaded. Downloads always unpack the full pack (.po, .mo and .l10n.php).

The same check runs in the install/update hooks, so unchanged translations are not re-downloaded there either.

Credits

This package was started by Angry Creative, has been rewritten by Bjørn Johansen, integrates compatibility changes made by Mirai and was updated to support Composer v2. The WPPack edition modernizes the codebase for PHP 8.2+.

License

GPL-2.0-or-later

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固