-
Notifications
You must be signed in to change notification settings - Fork 35
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
AUT-3675: make translation with new prefix #4035
Conversation
Front-end summary Node 18
|
…logy Feature/aut 3624/add new terminology
$pattern = '/' . self::LANG_PREFIX . '$/'; | ||
if (!preg_match($pattern, $localeDir, $matches)) { | ||
$path = $localesPath . '/' . $localeDir; | ||
if ($localeDir[0] != '.' && @is_dir($path)) { | ||
// Look if the lang.rdf can be read. | ||
$languageModelFile = $path . '/lang.rdf'; | ||
if (@file_exists($languageModelFile) && @is_readable($languageModelFile)) { | ||
$files[] = $languageModelFile; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may impact existing functionality. I recommend to extract this business logic into different service and unit service. I also recommend when replacing business logic here to use proxy approach maybe including Feature Flag to keep it safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to clarify what do you mean with Business logic? Only my added if condition or whole logic inside foreach
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand this answer. You are adding new business logic into existing service. This will impact other parts of the code that is using models/classes/class.LanguageService.php
. You should make sure it will not brake anything and for this you need to isolate impact of your change. I would recommend to create new Sprout class with method getLanguageFiles
overloaded.
private function checkPrefix(string $language): string | ||
{ | ||
if (!$this->isContainPrefix($language)) { | ||
$localesDir = 'views/locales'; | ||
$dir = dirname(__FILE__) . '/../../../' . $localesDir . '/' . $this->addPrefix($language); | ||
if (is_dir($dir)) { | ||
$language = $this->addPrefix($language); | ||
} | ||
} | ||
|
||
return $language; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract this to exteranal service and unit test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Please, re-check again @bartlomiejmarszal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing empty lines on the end of php files
} | ||
return $mapName; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
Conflicts: views/js/loader/vendor.es5.min.js views/js/loader/vendor.es5.min.js.map views/js/loader/vendor.min.js.map
Fixed @pribi |
* | ||
*/ | ||
abstract public function checkPrefix(string $language): string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty line on the end of line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed @bartlomiejmarszal
Version
There are 0 BREAKING CHANGE, 12 features, 1 fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file change is not well readable. This is just reformatting? Could you skip reformatting for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are new code added at the bottom of the array, though.
I can move the first square bracket to the line 29. Is that ok?
* Concatenate prefix for Solar design translations | ||
* | ||
*/ | ||
protected function addPrefix(string $language): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You actually adding postfix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -467,7 +468,8 @@ public function editClassLabel() | |||
$this->setData('reload', true); | |||
} | |||
|
|||
$this->setData('formTitle', __('Edit class %s', \tao_helpers_Display::htmlize($class->getLabel()))); | |||
$getLabel = MapLabelNameService::mapLabelName($class->getLabel()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you call it as you would call service?
public function __construct( | ||
LayoutHelper $layoutHelper | ||
) { | ||
$this->layoutHelper = $layoutHelper; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function __construct( | |
LayoutHelper $layoutHelper | |
) { | |
$this->layoutHelper = $layoutHelper; | |
} | |
public function __construct(LayoutHelper $layoutHelper) { | |
$this->layoutHelper = $layoutHelper; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
namespace oat\tao\helpers; | ||
use oat\tao\helpers\Layout; | ||
|
||
class MapLabelNameService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not understand purpose of this class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several places in the UI take the Label name from the PHP code. To set the correct Label for the translation, I need to map the PHP names with the translation IDs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you point me the UI that will be impacted by your change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was reviewing this with @pribi and I think I understand purpose of this.
Looking into usage of actions/class.RdfController.php
you will make a change translation for Items.
I understand that Items now should be renamed? WIll we rename root class Item? Do we want to apply this change everywhere? To each client and each instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -107,6 +110,7 @@ class tao_scripts_TaoTranslate extends tao_scripts_Runner | |||
protected $verbose = false; | |||
// --- OPERATIONS --- | |||
|
|||
private ?AbstractSolarThemeHelper $solarThemeHelper; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How this could be null? It is defined in ServiceProvider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
*/ | ||
private static function checkPrefix(string $language): string | ||
{ | ||
if (!self::isContainPrefix($language)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be under feature flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature flag is called inside isContainPrefix
* Check and Add prefix for Solar design translations | ||
* | ||
*/ | ||
private static function checkPrefix(string $language): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this class itself initiates statically. It's not using construct method
} | ||
|
||
/** | ||
* Check and Add prefix for Solar design translations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this check about? If I check something and it fails I throw an error and you seem to modify return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the ticket there is a condition to check for a new translation, if there is no new translation then use a normal translation. That's why I check via is_dir
. If the comment doesn't fit, is there any suggestion on how to change it?
Related to: https://oat-sa.atlassian.net/browse/AUT-3675
Summary
It makes translations with new prefix
To create and update new local files:
// from Docker container php tao/scripts/taoTranslate.php -v -a=create -e=taoQtiItem -l=en-us```