Skip to content

Commit

Permalink
Rewrote js/mage/translate.js without prototypejs (#3662)
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano authored Feb 11, 2024
1 parent d13beac commit c105b6e
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions js/mage/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,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) 2022-2024 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);
});
}
}
};
}

0 comments on commit c105b6e

Please sign in to comment.