mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-16 05:18:38 +01:00
15 lines
662 B
JavaScript
15 lines
662 B
JavaScript
export function t(str = "", replacementString, requestedKey){
|
|
const calculatedKey = str.toUpperCase().replace(/ /g, "_").replace(/[^a-zA-Z0-9\-\_\*\{\}\?]/g, "").replace(/\_+$/, "");
|
|
const value = requestedKey === undefined ? window.LNG && window.LNG[calculatedKey] : window.LNG && window.LNG[requestedKey];
|
|
return reformat(
|
|
value || str || "",
|
|
str
|
|
).replace("{{VALUE}}", replacementString);
|
|
}
|
|
|
|
function reformat(translated, initial){
|
|
if(initial[0] && initial[0].toLowerCase() === initial[0]){
|
|
return translated || "";
|
|
}
|
|
return (translated[0] && translated[0].toUpperCase() + translated.substring(1)) || "";
|
|
}
|