mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Changes include: 1) Remove underscore-string and sprintf-js packages as we were using only %s. Instead, added a function to do the same. Also changed gettext to behave like sprintf directly. 2) backgrid.sizeable.columns was not used anywhere, removed. @babel/polyfill is deprecated, replaced it with core-js. 3) Moved few css to make sure they get minified and bundled. 4) Added Flask-Compress to send static files as compressed gzip. This will reduce network traffic and improve initial load time for pgAdmin. 5) Split few JS files to make code reusable. 6) Lazy load few modules like leaflet, wkx is required only if geometry viewer is opened. snapsvg loaded only when explain plan is executed. This will improve sqleditor initial opening time. Reviewed By: Khushboo Vashi Fixes #4701
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
/////////////////////////////////////////////////////////////
|
|
//
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
//
|
|
// Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
|
// This software is released under the PostgreSQL Licence
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
define(['translations'], function (translations) {
|
|
|
|
/***
|
|
* This method behaves as a drop-in replacement for flask translation rendering.
|
|
* It uses the same translation file under the hood and uses flask to determine the language.
|
|
* It is slightly tweaked to work like sprintf
|
|
* ex. translate("some %s text", "cool")
|
|
*
|
|
* @param {String} text
|
|
*/
|
|
return function gettext(text) {
|
|
|
|
var rawTranslation = translations[text] ? translations[text] : text;
|
|
|
|
if(arguments.length == 1) {
|
|
return rawTranslation;
|
|
}
|
|
|
|
try {
|
|
let replaceArgs = arguments;
|
|
return rawTranslation.split('%s')
|
|
.map(function(w, i) {
|
|
if(i > 0) {
|
|
if(i < replaceArgs.length) {
|
|
return [replaceArgs[i], w].join('');
|
|
} else {
|
|
return ['%s', w].join('');
|
|
}
|
|
} else {
|
|
return w;
|
|
}
|
|
})
|
|
.join('');
|
|
} catch(e) {
|
|
console.error(e);
|
|
return rawTranslation;
|
|
}
|
|
};
|
|
});
|