Skip to content
New issue

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

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

Already on GitHub? # to your account

Rewrote js/mage/translate.js without prototypejs #3662

Merged
merged 6 commits into from
Feb 11, 2024
Merged
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
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);
});
}
}
};
}