定制 itk-dev/drupal_translation_extractor 二次开发

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

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

itk-dev/drupal_translation_extractor

Composer 安装命令:

composer require itk-dev/drupal_translation_extractor

包简介

drupal_translation_extractor

README 文档

README

Extracts translations from PHP files, Twig templates and JavaScripts files.

This Drupal translation extractor stands on the shoulders of giants:

Installation

composer require --dev itk-dev/drupal_translation_extractor:^1.0
drush pm:install drupal_translation_extractor

Use

The main entrypoint is the drupal_translation_extractor:translation:extract Drush command. This command is basically Symfony's translation:extract console command with a few changes and additions outlined below.

Changes from the Symfony command

The bundle argument doesn't make sense and has been removed.

The --clean option is a NOP since it doesn't make sense for our use. We always write only existing translations.

A new argument has been added:

source The source path to extract translations from. For convenience, module:«name» and theme:«name» can be used in the value and will be expanded to the full path to the module and/or theme respectively, i.e. module:my_custom_module will be expanded to web/modules/custom/my_custom_module, say.

A new option has been added:

--output The output path. The value can use these placeholders:

Name Value
%locale The locale being extracted
%module The module name if specified using module:… in source
%source_dir The directory of %source
%source The expanded value of source
%theme The theme name if specified using theme:… in source
%language1 Alias for %locale
%project 1 Alias for either %module or %theme (whichever is set)

Example

Running

drush drupal_translation_extractor:translation:extract da --dump-messages --force module:my_modules --output=%source/translation/%module.%locale.po

will find translations in all PHP, Twig and JavaScript files in the web/modules/custom/my_module directory and write the result to web/modules/custom/my_module/translation/my_module.da.po.

Note

Much of the code in this module is stolen frombased on Symfony components and therefore we do not use Drupal coding standards.

Footnotes

  1. Matching placeholders used the Locale module (cf. locale.api.php). 2

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固