初始版本提交
This commit is contained in:
19
src/locales/bpmn/customTranslate.ts
Normal file
19
src/locales/bpmn/customTranslate.ts
Normal file
@ -0,0 +1,19 @@
|
||||
export default function customTranslate(translations) {
|
||||
return function (template, replacements) {
|
||||
replacements = replacements || {};
|
||||
// Translate
|
||||
template = translations[template] || template;
|
||||
|
||||
// Replace
|
||||
return template.replace(/{([^}]+)}/g, function (_, key) {
|
||||
let str = replacements[key];
|
||||
if (
|
||||
translations[replacements[key]] !== null &&
|
||||
translations[replacements[key]] !== undefined
|
||||
) {
|
||||
str = translations[replacements[key]];
|
||||
}
|
||||
return str || '{' + key + '}';
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user