@mongez/localization
Version:
A simple i18n localization handler for browsers and nodejs
13 lines (12 loc) • 504 B
JavaScript
/**
* Convert the placeholders for the given translation
*/
function plainConverter(translation, placeholders = {}, placeholderPattern = /:([a-zA-Z0-9_-]+)/g) {
return translation.replace(placeholderPattern, (match, key) => {
const value = placeholders[key];
if (value === undefined) {
return match; // Return the original placeholder if no match is found
}
return value.toString();
});
}export{plainConverter};//# sourceMappingURL=converters.js.map