Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Api/AttributeProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/
interface AttributeProviderInterface
{
const string SKIP_TRANSLATION = 'skip_translation';
const string SKIP_TRANSLATION_LABEL = 'Skip translation';
const string SKIP_TRANSLATION_NOTE = 'Uncheck to re-translate';
const string LAST_TRANSLATION = 'last_translation_date';
const string LAST_TRANSLATION_LABEL = 'Last translation date';
const SKIP_TRANSLATION = 'skip_translation';
const SKIP_TRANSLATION_LABEL = 'Skip translation';
const SKIP_TRANSLATION_NOTE = 'Uncheck to re-translate';
const LAST_TRANSLATION = 'last_translation_date';
const LAST_TRANSLATION_LABEL = 'Last translation date';
}
2 changes: 1 addition & 1 deletion Block/Adminhtml/CmsBlock/GenerateTranslationsButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class GenerateTranslationsButton extends GenericButton implements ButtonProviderInterface
{
const string CMSBLOCK_TRANSLATION_CONTROLLER_PATH = 'automatic_translation/cms_block/generate';
const CMSBLOCK_TRANSLATION_CONTROLLER_PATH = 'automatic_translation/cms_block/generate';

/**
* @param Context $context
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/CmsPage/GenerateTranslationsButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class GenerateTranslationsButton extends GenericButton implements ButtonProviderInterface
{
const string CMSPAGE_TRANSLATION_CONTROLLER_PATH = 'automatic_translation/cms_page/generate';
const CMSPAGE_TRANSLATION_CONTROLLER_PATH = 'automatic_translation/cms_page/generate';

/**
* @param Context $context
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# Automatic Translation
## [2.1.0] - 20/03/2026
### Changed
- Minimum PHP version lowered from 8.3 to 8.2
- Removed typed constants (PHP 8.3 feature) for 8.2 compatibility

## [2.0.2] - 20/03/2026
### Fixed
- Fixed CMS page plain text fields (title, heading, meta title, meta keywords, meta description) not being translated
- Added URL key (identifier) to CMS page translatable fields
- Fixed URL key slug sanitization using correct field name (identifier instead of url_key)
- Fixed TranslateParsedContent for string input: translates text before handling widget directives

## [2.0.1] - 20/03/2026
### Fixed
- Fixed product translate button passing null instead of 0 to isEnable() for default store

## [2.0.0] - 12/03/2026
### Changed
- **BREAKING**: Minimum PHP version raised to 8.3
Expand Down
50 changes: 25 additions & 25 deletions Helper/ModuleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@

class ModuleConfig extends AbstractHelper
{
const string SECTION = 'ai_integration/automatic_translation';

const string GENERAL_GROUP = self::SECTION . '/general';
const string CATALOG_GROUP = self::SECTION . '/catalog';
const string ENGINE_GROUP = self::SECTION . '/translations_engine';

const string ENABLE = self::GENERAL_GROUP . '/enable';
const string SOURCE_LANGUAGE = self::GENERAL_GROUP . '/source_language';
const string DESTINATION_LANGUAGE = 'general/locale/code';

const string TXT_PRODUCT_ATTR = self::CATALOG_GROUP . '/text_attribute_to_translate';
const string SELECT_PRODUCT_ATTR = self::CATALOG_GROUP . '/select_attribute_to_translate';
const string ENABLE_PERIODIC = self::CATALOG_GROUP . '/enable_periodic_retranslation';
const string RETRANSLATION_PERIOD = self::CATALOG_GROUP . '/retranslation_period';
const string TRANSLATE_DISABLED = self::CATALOG_GROUP . '/translate_disabled';
const string ENABLE_URL_REWRITE = self::CATALOG_GROUP . '/enable_url_rewrite';

const string ENGINE = self::ENGINE_GROUP . '/engine';
const string DEEPL_AUTH_KEY = self::ENGINE_GROUP . '/deepl_auth_key';
const string OPEN_AI_ORG_ID = self::ENGINE_GROUP . '/openai_org_id';
const string OPEN_AI_API_KEY = self::ENGINE_GROUP . '/openai_api_key';
const string OPEN_AI_PROJECT_ID = self::ENGINE_GROUP . '/openai_project_id';
const string OPEN_AI_MODEL = self::ENGINE_GROUP . '/openai_model';
const string GEMINI_API_KEY = self::ENGINE_GROUP . '/gemini_api_key';
const string GEMINI_MODEL = self::ENGINE_GROUP . '/gemini_model';
const SECTION = 'ai_integration/automatic_translation';

const GENERAL_GROUP = self::SECTION . '/general';
const CATALOG_GROUP = self::SECTION . '/catalog';
const ENGINE_GROUP = self::SECTION . '/translations_engine';

const ENABLE = self::GENERAL_GROUP . '/enable';
const SOURCE_LANGUAGE = self::GENERAL_GROUP . '/source_language';
const DESTINATION_LANGUAGE = 'general/locale/code';

const TXT_PRODUCT_ATTR = self::CATALOG_GROUP . '/text_attribute_to_translate';
const SELECT_PRODUCT_ATTR = self::CATALOG_GROUP . '/select_attribute_to_translate';
const ENABLE_PERIODIC = self::CATALOG_GROUP . '/enable_periodic_retranslation';
const RETRANSLATION_PERIOD = self::CATALOG_GROUP . '/retranslation_period';
const TRANSLATE_DISABLED = self::CATALOG_GROUP . '/translate_disabled';
const ENABLE_URL_REWRITE = self::CATALOG_GROUP . '/enable_url_rewrite';

const ENGINE = self::ENGINE_GROUP . '/engine';
const DEEPL_AUTH_KEY = self::ENGINE_GROUP . '/deepl_auth_key';
const OPEN_AI_ORG_ID = self::ENGINE_GROUP . '/openai_org_id';
const OPEN_AI_API_KEY = self::ENGINE_GROUP . '/openai_api_key';
const OPEN_AI_PROJECT_ID = self::ENGINE_GROUP . '/openai_project_id';
const OPEN_AI_MODEL = self::ENGINE_GROUP . '/openai_model';
const GEMINI_API_KEY = self::ENGINE_GROUP . '/gemini_api_key';
const GEMINI_MODEL = self::ENGINE_GROUP . '/gemini_model';

/**
* @param EncryptorInterface $encryptor
Expand Down
4 changes: 2 additions & 2 deletions Model/Config/Source/SelectAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

class SelectAttributes implements OptionSourceInterface
{
const array ATTRIBUTE_TYPES = [
const ATTRIBUTE_TYPES = [
'select',
'multiselect'
];
const array ATTRIBUTES_TO_EXCLUDE = [
const ATTRIBUTES_TO_EXCLUDE = [
'custom_design',
'custom_layout',
'custom_layout_update_file',
Expand Down
8 changes: 4 additions & 4 deletions Model/Config/Source/TextAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

class TextAttributes implements OptionSourceInterface
{
const string GALLERY_ALT_ATTRIBUTE_CODE = 'gallery_alt';
const array GALLERY_ALT_IMAGE_ATTRIBUTE = [
const GALLERY_ALT_ATTRIBUTE_CODE = 'gallery_alt';
const GALLERY_ALT_IMAGE_ATTRIBUTE = [
'value' => self::GALLERY_ALT_ATTRIBUTE_CODE,
'label' => 'Gallery image alt text'
];
const array ATTRIBUTE_TYPES = [
const ATTRIBUTE_TYPES = [
'text',
'textarea'
];
const array ATTRIBUTES_TO_EXCLUDE = [
const ATTRIBUTES_TO_EXCLUDE = [
'sku',
'tier_price',
'category_ids',
Expand Down
2 changes: 1 addition & 1 deletion Model/Translator/DeepL.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class DeepL implements TranslatorInterface
{
const array REGIONAL_VARIANTS_LANGUAGES = [
const REGIONAL_VARIANTS_LANGUAGES = [
'en',
'pt',
'es',
Expand Down
2 changes: 1 addition & 1 deletion Plugin/AdminhtmlCategoryBeforeSavePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class AdminhtmlCategoryBeforeSavePlugin
{
const array CATEGORY_TRANSLATABLE_ATTRIBUTES = [
const CATEGORY_TRANSLATABLE_ATTRIBUTES = [
'name',
'description',
'url_key',
Expand Down
1 change: 1 addition & 0 deletions Service/ProductTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function translateProduct(
* @param string $targetLanguage
* @param string $sourceLanguage
* @throws LocalizedException
* @throws Exception
*/
protected function translateGalleryAlternativeTexts(
ProductInterface $product,
Expand Down
8 changes: 4 additions & 4 deletions Service/TextChunker.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

class TextChunker
{
const int MAX_CHUNK_SIZE = 4500;
const int HALF_CHUNK_SIZE = 2250;
const MAX_CHUNK_SIZE = 4500;
const HALF_CHUNK_SIZE = 2250;

const string BLOCK_TAG_PATTERN = '#(</(?:p|div|h[1-6]|ul|ol|li|table|tr|blockquote|section|article|header|footer|figure|figcaption)>)#i';
const BLOCK_TAG_PATTERN = '#(</(?:p|div|h[1-6]|ul|ol|li|table|tr|blockquote|section|article|header|footer|figure|figcaption)>)#i';

const array PLAIN_TEXT_PATTERNS = [
const PLAIN_TEXT_PATTERNS = [
'/(\n\n)/',
'/(\n)/',
'/((?<=[.!?])\s+)/',
Expand Down
10 changes: 5 additions & 5 deletions Service/TranslateParsedContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

class TranslateParsedContent
{
const string WIDGET_PATTERN = '/\{\{widget\s[^}]*\}\}/';
const array TRANSLATABLE_WIDGET_PARAMS = ['anchor_text', 'title', 'description'];
const array TRANSLATABLE_REPEATABLE_PARAMS = ['title', 'content', 'button', 'image_alt'];
const int JSON_ENCODE_FLAGS = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
const WIDGET_PATTERN = '/\{\{widget\s[^}]*\}\}/';
const TRANSLATABLE_WIDGET_PARAMS = ['anchor_text', 'title', 'description'];
const TRANSLATABLE_REPEATABLE_PARAMS = ['title', 'content', 'button', 'image_alt'];
const JSON_ENCODE_FLAGS = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;

/**
* @param Service $serviceHelper
Expand Down Expand Up @@ -102,7 +102,7 @@ function (array $matches) use (&$contentSettingsMap): string {
}
}

$result = strpos($requestPostValue, 'data-content-type="html"') !== false
$result = str_contains($requestPostValue, 'data-content-type="html"')
? $this->serviceHelper->encodePageBuilderHtmlBox($requestPostValue)
: $requestPostValue;

Expand Down
4 changes: 2 additions & 2 deletions Setup/Patch/Data/MigrateConfigPaths.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

class MigrateConfigPaths implements DataPatchInterface
{
const array ENCRYPTED_OLD_PATHS = [
const ENCRYPTED_OLD_PATHS = [
'automatic_translation/translations_engine/deepl_auth_key',
'automatic_translation/translations_engine/openai_api_key',
'automatic_translation/translations_engine/gemini_api_key',
];

const array MAPPINGS = [
const MAPPINGS = [
'automatic_translation/general/enable' => 'ai_integration/automatic_translation/general/enable',
'automatic_translation/general/source_language' => 'ai_integration/automatic_translation/general/source_language',
'automatic_translation/general/destination_language' => 'general/locale/code',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class TranslationStores extends AbstractModifier
{
const string GROUP_CODE = 'translation-stores';
const GROUP_CODE = 'translation-stores';

/**
* @param StoreSwitcher $storeSwitcher
Expand Down Expand Up @@ -55,9 +55,7 @@ public function modifyMeta(array $meta): array
}

$meta = $this->customizeSwitchStoreModal($meta);
$meta = $this->customizeTranslationStoresList($meta);

return $meta;
return $this->customizeTranslationStoresList($meta);
}

/**
Expand Down Expand Up @@ -132,7 +130,6 @@ protected function getTranslationStores(): array
);
$categoryStoreIds = $currentCategory->getStoreIds();

/** @var Website $website */
foreach ($this->storeSwitcher->getWebsites() as $website) {
$stores = $website->getStores();
/** @var Store $store */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class TranslationStores extends AbstractModifier
{
const string GROUP_CODE = 'translation-stores';
const GROUP_CODE = 'translation-stores';

/**
* @param StoreSwitcher $storeSwitcher
Expand Down Expand Up @@ -132,7 +132,6 @@ protected function getTranslationStores(): array
);
$productStoreIds = $currentProduct->getStoreIds();

/** @var Website $website */
foreach ($this->storeSwitcher->getWebsites() as $website) {
$stores = $website->getStores();
/** @var Store $store */
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"MIT"
],
"require": {
"php": ">=8.3",
"php": ">=8.2",
"magento/framework": "*",
"magento/module-catalog": "^104.0.0",
"deeplcom/deepl-php": "^1",
Expand Down