Skip to content
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

Feature/aut 3624/add translation to fe labels #4054

4 changes: 3 additions & 1 deletion actions/class.RdfController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
use oat\generis\model\resource\Contract\ResourceDeleterInterface;
use oat\tao\model\metadata\exception\InconsistencyConfigException;
use oat\tao\model\resources\Exception\PartialClassDeletionException;
use oat\tao\helpers\MapLabelNameService;

/**
* The TaoModule is an abstract controller,
Expand Down Expand Up @@ -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());
pribi marked this conversation as resolved.
Show resolved Hide resolved
$this->setData('formTitle', __('Edit class %s', tao_helpers_Display::htmlize($getLabel)));
$this->setData('myForm', $myForm->render());
$this->setView('form.tpl', 'tao');
}
Expand Down
1 change: 1 addition & 0 deletions helpers/class.Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,5 @@ private static function getApplicationService(): ApplicationService
/** @noinspection PhpIncompatibleReturnTypeInspection */
return ServiceManager::getServiceManager()->get(ApplicationService::SERVICE_ID);
}

pribi marked this conversation as resolved.
Show resolved Hide resolved
}
52 changes: 52 additions & 0 deletions helpers/mapLabelNameService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
pribi marked this conversation as resolved.
Show resolved Hide resolved

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2024 (original work) Open Assessment Technologies SA ;
*/

namespace oat\tao\helpers;
use oat\tao\helpers\Layout;

class MapLabelNameService
{

private const ITEM = 'Item';
private const MEDIA = 'Media';
private const DELIVERY = 'Delivery';
private const ASSETS = 'Assets';

// New terms for isSolarDesignEnabled FF
private $mapLabelNames = [
pribi marked this conversation as resolved.
Show resolved Hide resolved
self::ITEM => 'Item',
self::MEDIA => 'Asset',
self::DELIVERY => 'Delivery',
self::ASSETS => 'Asset'
];

/**
* @param $labelName
* @return string
*/
public function mapLabelName(string $labelName): string
{
$mapName = $labelName;
if (Layout::isSolarDesignEnabled()) {
$mapName = __(self::$mapLabelNames[$labelName]);
}
return $mapName;
}
pribi marked this conversation as resolved.
Show resolved Hide resolved
}
pribi marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 6 additions & 3 deletions views/js/lib/jsTree/jquery.tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

define(['jquery', 'layout/tree/helpers',], function($, helpers) {
define(['jquery', 'layout/tree/helpers', 'i18n'], function($, helpers, __) {
// jQuery plugin
$.tree = {
datastores : { },
Expand Down Expand Up @@ -67,7 +67,10 @@ define(['jquery', 'layout/tree/helpers',], function($, helpers) {
},
lang : {
new_node : "New folder",
loading : "Loading ..."
loading : "Loading ...",
"Item": __("Item"),
"Assembled Delivery ": __("Delivery"),
"Assets": __("Asset")
},
callback : {
beforechange: function(NODE,TREE_OBJ) { return true },
Expand Down Expand Up @@ -2013,7 +2016,7 @@ define(['jquery', 'layout/tree/helpers',], function($, helpers) {
str += "<ins " + (data.data.icon.indexOf("/") == -1 ? " class='" + data.data.icon + "' " : " style='background-image:url(\"" + data.data.icon + "\");' " ) + ">&nbsp;</ins>";
}
else str += "<ins>&nbsp;</ins>";
str += ( (typeof data.data.title).toLowerCase() != "undefined" ? data.data.title : data.data ) + "</a>";
str += ( (typeof data.data.title).toLowerCase() != "undefined" ? data.data.title : tree.settings.lang[data.data] ? tree.settings.lang[data.data] : data.data ) + "</a>";
}
if(data.children && data.children.length) {
str += '<ul>';
Expand Down
4 changes: 3 additions & 1 deletion views/templates/blocks/sections.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
use oat\tao\helpers\Template;
use oat\tao\helpers\Layout;
use oat\tao\helpers\MapLabelNameService;
pribi marked this conversation as resolved.
Show resolved Hide resolved

$xsrfTokenName = get_data('xsrf-token-name');
$sections = get_data('sections');
Expand Down Expand Up @@ -81,9 +82,10 @@ $sections = get_data('sections');
$node = $tree->get('rootNode');
}
if ($node) {
$className = MapLabelNameService::mapLabelName($tree->get('className'));
pribi marked this conversation as resolved.
Show resolved Hide resolved
Template::inc('blocks/search.tpl', 'tao', array(
'rootNode' => $node,
'searchLabel' => __('Search %s', $tree->get('className'))
'searchLabel' => __('Search %s', $className)
));
}
}
Expand Down