Skip to content

Issue 11175: fix i18n:collect-phrases so it also collects "translate args" #13470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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: 7 additions & 3 deletions setup/src/Magento/Setup/Module/I18n/Parser/Adapter/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class Html extends AbstractAdapter
* Covers
* <span><!-- ko i18n: 'Next'--><!-- /ko --></span>
* <th class="col col-method" data-bind="i18n: 'Select Method'"></th>
* <translate args="'Items in Cart'"/>
*/
const HTML_FILTER = "/i18n:\s?'(?<value>[^'\\\\]*(?:\\\\.[^'\\\\]*)*)'/i";
const HTML_FILTER = "/i18n:\s?'(?<value_i18n>[^'\\\\]*(?:\\\\.[^'\\\\]*)*)|translate args=\"'(?<value_translate_args>[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)'\"/i";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better deprecate this constant and add the new array with regular expressions for different cases with translation match. This approach will make the translations collecting process more clear.


/**
* {@inheritdoc}
Expand All @@ -44,8 +45,11 @@ protected function _parse()

preg_match_all(self::HTML_FILTER, $data, $results, PREG_SET_ORDER);
for ($i = 0; $i < count($results); $i++) {
if (!empty($results[$i]['value'])) {
$this->_addPhrase($results[$i]['value']);
if (!empty($results[$i]['value_i18n'])) {
$this->_addPhrase($results[$i]['value_i18n']);
}
if (!empty($results[$i]['value_translate_args'])) {
$this->_addPhrase($results[$i]['value_translate_args']);
}
}
}
Expand Down