2023-10-23 17:43:17 +05:30
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
|
//
|
2026-01-05 13:33:45 +05:30
|
|
|
// Copyright (C) 2013 - 2026, The pgAdmin Development Team
|
2023-10-23 17:43:17 +05:30
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
import translations from 'translations';
|
|
|
|
|
|
2024-12-16 14:52:56 +05:30
|
|
|
function gettextForTranslation(translations, ...replaceArgs) {
|
|
|
|
|
const text = replaceArgs[0];
|
|
|
|
|
let rawTranslation = translations[text] ? translations[text] : text;
|
|
|
|
|
|
|
|
|
|
if(arguments.length == 2) {
|
|
|
|
|
return rawTranslation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-23 17:43:17 +05:30
|
|
|
export default function gettext(text, ...args) {
|
2024-12-16 14:52:56 +05:30
|
|
|
return gettextForTranslation(translations, text, ...args);
|
2023-10-23 17:43:17 +05:30
|
|
|
}
|