msns/module-product-translation
Composer 安装命令:
composer require msns/module-product-translation
包简介
AI translation of product attributes across store views (configurable endpoint/model).
README 文档
README
AI translation of product attributes across store views for Magento 2, using any OpenAI-compatible chat endpoint (OpenAI, Mistral, OpenRouter, Ollama, LM Studio, a gateway…).
Translate name, description, short_description (configurable) from a source
store view into all the others. A tracking table records when each product/store was
translated and automatically flags it stale when the source content changes.
Features
- Configurable endpoint, API key and model — no SDK, no provider lock-in.
- Source store → all other store views; target language derived from each store's locale.
- Per-(product, store) tracking:
translated_at+ status (pending/translated/stale/error). - Stale detection on source change only: editing a product on the source store re-flags its translations; editing a translated store view does not.
- Run it three ways: a button on the product page (AJAX modal, live progress), a CLI command, or a cron (every 5 min).
Requirements
- Magento 2.4.x, PHP 8.2+
- An OpenAI-compatible chat-completions endpoint
Installation
composer require msns/module-product-translation
bin/magento module:enable Msns_ProductTranslation
bin/magento setup:upgrade
Or drop the module into app/code/Msns/ProductTranslation and run setup:upgrade.
Configuration
Stores → Configuration → MSNS → Product Translation
| Field | Description |
|---|---|
| Enabled | Master switch |
| Source store view | The store whose content is translated into the others |
| Attributes to translate | Comma-separated attribute codes (default name,description,short_description) |
| Prompt template | Placeholders: {{attribute}} {{language}} {{text}} {{product_name}} |
| API URL | OpenAI-compatible endpoint, e.g. https://api.openai.com/v1/chat/completions |
| API key | Stored encrypted; ignored by providers that don't require auth (Ollama/LM Studio) |
| Model | e.g. gpt-4o-mini, mistral-small, llama3.1, or any locally loaded model |
Inside Docker, point the URL at
http://host.docker.internal:<port>/...to reach a model running on the host.
Usage
Product page — click Translate to all stores. A modal shows per-store progress and the result.
CLI
bin/magento msns:translate --seed # queue every product × target store
bin/magento msns:translate --limit 50 # translate a batch of pending/stale rows
Cron — msns_product_translation_run processes pending/stale rows every 5 minutes.
How staleness works
On catalog_product_save_after, the module hashes the configured attributes at the source store
scope. If that hash differs from the one stored at translation time, the product's translated rows
are marked stale. A change on a target store view leaves the source hash untouched, so it never
re-flags — only the source store matters.
Testing
composer install
vendor/bin/phpunit
CI (.gitlab-ci.yml) runs the unit suite on every push.
License
Proprietary.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2026-06-24