From 43f233fc8d2fbb4d4ed73ca67f191d9509414166 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 18 Nov 2023 22:09:31 +0000 Subject: [PATCH 1/3] Rewrote js/mage/translate.js without prototypejs --- js/mage/translate.js | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/js/mage/translate.js b/js/mage/translate.js index 904dccf5b4b..3c64a7ac38e 100644 --- a/js/mage/translate.js +++ b/js/mage/translate.js @@ -7,33 +7,29 @@ * * @category Mage * @package js - * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2023 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -var Translate = Class.create(); -Translate.prototype = { - initialize: function(data){ - this.data = $H(data); - }, - - translate : function(){ - var args = arguments; - var text = arguments[0]; +class Translate { + constructor(data) { + this.data = new Map(Object.entries(data)); + } - if(this.data.get(text)){ + translate(text) { + if(this.data.has(text)) { return this.data.get(text); } return text; - }, - add : function() { + } + + add(keyOrObject, value) { if (arguments.length > 1) { - this.data.set(arguments[0], arguments[1]); - } else if (typeof arguments[0] =='object') { - $H(arguments[0]).each(function (pair){ - this.data.set(pair.key, pair.value); - }.bind(this)); + this.data.set(keyOrObject, value); + } else if (typeof keyOrObject == 'object') { + Object.entries(keyOrObject).forEach(([key, value]) => { + this.data.set(key, value); + }); } } -}; +} From 88ed524f012337d6354ebd4791f4d9453559b7f2 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 18 Nov 2023 22:17:56 +0000 Subject: [PATCH 2/3] Restored copyright lines --- js/mage/translate.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/mage/translate.js b/js/mage/translate.js index 3c64a7ac38e..e60b310b74a 100644 --- a/js/mage/translate.js +++ b/js/mage/translate.js @@ -7,7 +7,8 @@ * * @category Mage * @package js - * @copyright Copyright (c) 2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) + * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ From 625e497cde2fd852a12531b5e2e1f5edcf431be5 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Thu, 25 Jan 2024 11:59:26 +0000 Subject: [PATCH 3/3] copyright year updated --- js/mage/translate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/mage/translate.js b/js/mage/translate.js index e60b310b74a..55dc080e8ed 100644 --- a/js/mage/translate.js +++ b/js/mage/translate.js @@ -8,7 +8,7 @@ * @category Mage * @package js * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */