定制 itmar/add_lazy_pot_file 二次开发

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

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

itmar/add_lazy_pot_file

最新稳定版本:v1.0.0

Composer 安装命令:

composer require itmar/add_lazy_pot_file

包简介

This is a command to add information corresponding to lazy loading to the POT file for functioning the translation function provided by WordPress.

README 文档

README

Provides a function that adds the path information of the calling file of lazy loading to the translation template file (POT file) corresponding to the translation function.

Quick links: Using | Installing | Notes | Support

When to use

When using a module that is not always used, delaying loading it until it is time to use it is called lazy loading, and React provides a function called React.lazy. When you use this, the transpiled js file is divided into 1) a file that is loaded with a delay, and 2) a file that calls it. When the part using the translation function is stored in ①, wp i18n make-pot, the WP-CLI command for creating a POT file, outputs only the path information of ① to the POT file, and the path of ② No information is output. ② If you create a Javascript translation file based on a POT file that does not have file path information, you will not be able to render the translated result. Therefore, the path information in ② must be recorded in the POT file. This WP-CLI command provides the ability to add ② file path information to the file generated with wp i18n make-pot.

Using

wp add_source_path [text domain]

Among the plugins installed in WordPress, select the js file that uses the React.lazy function from the build folder of the plugin that has the text domain information [text domain] as the plugin information, and select the js file that uses the React.lazy function. Based on the lazy loading information read from , write the path information of the selected js file to the POT file and overwrite it.

Installing

This package is provided as a Composer project, so install it using the Composer installation procedure.

  1. Clone GitHub repository: Navigate to the folder where WordPress is installed, open a command prompt or terminal, and clone the repository using Git commands as follows:
git clone https://github.com/itmaroon/add_lazy_pot_file.git
  1. Installing Composer dependencies Change to the directory of the cloned repository.
cd ./add_lazy_pot_file

Install dependencies.

composer install

Notes

  1. This WP-CLI command assumes support for the translation system of the plugin that provides the Gutenberg block component.
  2. Text Domain: must be set in the plugin information (comment at the beginning of the PHP file that is the entry point of the plugin).
  3. A POT file must be created in advance using wp i18n make-pot. This file name is [text domain].pot and must be located in one of the folders within the plugin's root folder.

Support

If you have any questions, please contact us at the following email address. master@itmaroon.net

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-19