承接 wubinworks/module-translation 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

wubinworks/module-translation

Composer 安装命令:

composer require wubinworks/module-translation

包简介

This module [1] Adds translation data from [module or theme root]/i18n/Js/[locale].csv to frontend translation dictionary. [2] Enables Module to override Theme, Language Pack and DB translations by creating CSV file in specific location inside the Module.

README 文档

README

(Everything talked here is for Magento 2.4. See Requirements Section.)

This module, which provides 2 features, is designed as a dependency for making other modules/themes.

  1. During deployment, Magento scans static .js and .html files and picks up translatable strings from them.
    Then Magento generates a js-traslation.json file.
    This file is a dictionary file used for frontend translation,
    For example: <!-- ko i18n: 'Translate Me!' --><!-- /ko -->
    Unfortunately, translatable strings in .phtml(and .php) files are not picked up by Magento(for some reasons).
    If $.mage.__('Some Text') is in .phtml files, it won't be translated.
    This module can force extra data from a separate file(i.e., [module or theme root]/i18n/Js/[locale].csv) to go to js-traslation.json.

  2. Magento loads translation data in the order below:

 |  Module translation: [module root]/i18n/[locale].csv
 |  Language Pack translation
 |  Theme translation: [theme root]/i18n/[locale].csv
\|/ Database translation

Then these translation data are merged and the merge rule is "LAST ONE WINS", which means Database translation overrides everything else.
However, In some cases, especially when doing local development to translate very general phrases in specific business field, the Module creator wants to override Language Pack and Theme translations without modifying those third party packages.
This module adds extra locations for translation files(CSV), so the loading order becomes:

 |  Module translation: [module root]/i18n/[locale].csv

 |  Language Pack translation

 |  Theme translation: [theme root]/i18n/[locale].csv

 |  Database translation

 |  Extra Module translation: [module root]/i18n/i18n/[locale].csv

\|/ Extra Theme translation: [theme root]/i18n/i18n/[locale].csv(last-one-wins)

This module works under Store Emulation, too.

Usage and Example

1. Append(merge) translation into js-traslation.json:
Create <module or theme root>/i18n/Js/<locale>.csv like a normal translation CSV file, then its content will go to js-traslation.json(even the phrase cannot be found as a translatable string in static files).

2. Override Language Pack or Theme translations:
Create [module or theme root]/i18n/i18n/[locale].csv like a normal translation CSV file, then it will work.

Check examples of this module inside the i18n folder.

i18n/ja_JP.csv

"###Translate Me!###","翻訳して!"

i18n/i18n/ja_JP.csv

"###Translate Me!###","翻訳してください!(Override)"

i18n/Js/ja_JP.csv

"###This phrase will go to js-translation.json anyway.###","このフレーズは必ずjs-translation.jsonに出現する。"
"###This phrase will be overridden.###","このフレーズはオーバーライドされる"

i18n/i18n/Js/ja_JP.csv

"###This phrase will be overridden.###","このフレーズをオーバーライドした"

Output:

###Translate Me!### -> 翻訳してください!(Override)

Output in js-translation.json:

###This phrase will go to js-translation.json anyway.### -> このフレーズは必ずjs-translation.jsonに出現する。
###This phrase will be overridden.### -> このフレーズをオーバーライドした

Requirements

Magento 2.4

Installation

composer require wubinworks/module-translation

wubinworks/module-translation 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2023-09-22