承接 mage-os/module-automatic-translation 相关项目开发

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

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

mage-os/module-automatic-translation

Composer 安装命令:

composer require mage-os/module-automatic-translation

包简介

Automatic AI content translation for Mage-OS.

README 文档

README

Overview

The MageOS Automatic Translation module allows you to automatically translate content in your Magento store, such as products, categories, pages, and static blocks, using AI-based translation engines. The module is natively integrated with DeepL, OpenAI and Google Gemini, but it can be easily extended to support other translation engines.

Installation

  1. Install the module via Composer:

    composer require mage-os/module-automatic-translation
  2. Enable the module:

    bin/magento module:enable MageOS_AutomaticTranslation
  3. Run the setup upgrade command:

    bin/magento setup:upgrade

Features

Product Translation

The product translation process is divided into two parts:

  1. Textual attributes – The translated value is directly set in the product entity.
  2. Select and Multiselect attributes – The translation of these attributes involves translating the labels of the options, not the option IDs, as option IDs remain consistent across languages.

The module automatically translates products via scheduled cron jobs for both textual and select/multiselect attributes. You can also manually translate products through a backoffice button available in the product editing page.

Cron Jobs for Product Translation:

  • The product translation process runs according to a cron schedule, which can be configured via the Product translation cron expression in the configuration.
  • For select/multiselect attribute options, another cron job is scheduled, configurable via the Select attributes translation cron expression.

Category Translation

Categories are translated only manually via a backoffice button. This is because the number of categories is usually much smaller than the number of products, and thus the manual translation process is more efficient.

For categories, only the following fields are translated:

  • Name
  • Description
  • URL Key
  • Meta information

Note: If you add custom attributes to categories programmatically, it is the developer’s responsibility to decide whether to translate these attributes and add them to the translation list programmatically.

Pages and Static Blocks Translation

Similar to categories, pages and static blocks can only be translated manually via a backoffice button. However, because Magento does not support multiple language versions for pages and static blocks, translation will overwrite the original content when saving. To prevent losing the original content, it is recommended to use the "Save & Duplicate" feature in the backoffice to create a copy of the page or block before translating it.

Retranslation of Products

When the module translates a product for a storeview, it values two attributes specific to that product and that storeview: "skip translation" set to "yes" and "last translation date" with the date of the translation. These attributes are automatically created by the module during installation and are updated each time the product is translated.

This process is used to "flag" the product as "already translated" preventing it from being translated again in future executions, thus improving performance.

However, if the merchant changes the basic content of the product after translation, it may need to be retranslated. The merchant can do this manually by using the button in the backoffice or by setting the "skip translation" attribute to "no" and saving the product. These operations are feasible if there are few products to be edited.

If, however, there are many products to be retranslated or the underlying content changes frequently, it may be useful to enable automatic retranslation. When enabled, this feature also includes products with the "skip translation" attribute set to "yes" in the translation process if the date in the "last translation date" attribute is older than a specified number of days, which can be configured in the settings.

Translation Engines

  • DeepL, OpenAI and Google Gemini are the supported engines by default. You can easily extend the module to support additional translation engines by creating a class that implements the MageOS\AutomaticTranslation\Api\TranslatorInterface.
  • The engine is selected under Stores > Configuration > MageOS > Automatic translation with AI > Translation engine.

Configuration Options

The module provides several configuration options under Stores > Configuration > Services > AI Integration > Automatic translation with AI:

General Configuration

  • Enable: Enables or disables the module. This setting is configurable per store view, allowing you to translate only certain languages.
  • Source Language: Defines the source language of your content. This is typically set to the language in which your products were initially created.
  • Destination Language: This is the target language for translation, which corresponds to the store view's language.

Catalog Translation Options

  • Product Text Attributes to Translate: Select the textual attributes you want to translate (e.g., name, description).
  • Product Select/Multiselect Attributes to Translate: Select which select/multiselect attributes to translate.
  • Translate Disabled Products: Skips disabled products during translation to improve performance.
  • Product Translation Cron Expression: Schedules the product translation process.
  • Select Attributes Translation Cron Expression: Schedules the translation of select/multiselect attributes.
  • Enable Periodic Retranslation & Retranslation Period (in days): Enables automatic retranslation for products if their translation is outdated (older than a set number of days).

Translation Engine Configuration

  • Engine: Choose the translation engine (DeepL or OpenAI or Google Gemini).
  • API Credentials: Configure API credentials for the selected engine.
  • Model Language (for OpenAI & Google Gemini): This field is dynamic and will be populated once valid API credentials are entered.

Adding Additional Translation Engines

To add a new translation engine, you need to:

  1. Create a class implementing MageOS\AutomaticTranslation\Api\TranslatorInterface.
  2. Extend the module to add the new engine's API configuration in system.xml.
  3. Add an after plugin to modify the list of selectable engines in \MageOS\AutomaticTranslation\Model\Config\Source\TranslationEngineList::toOptionArray.

mage-os/module-automatic-translation 适用场景与选型建议

mage-os/module-automatic-translation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20k 次下载、GitHub Stars 达 29, 最近一次更新时间为 2024 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 29
  • Watchers: 3
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-01