You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
873 B
32 lines
873 B
import translations from '../lang/zh'
|
|
|
|
// export default function customTranslate(template, replacements) {
|
|
// replacements = replacements || {}
|
|
//
|
|
// // Translate
|
|
// template = translations[template] || template
|
|
//
|
|
// // Replace
|
|
// return template.replace(/{([^}]+)}/g, function(_, key) {
|
|
// var str = replacements[key]
|
|
// if (
|
|
// translations[replacements[key]] !== null &&
|
|
// translations[replacements[key]] !== 'undefined'
|
|
// ) {
|
|
// str = translations[replacements[key]]
|
|
// }
|
|
// return str || '{' + key + '}'
|
|
// })
|
|
// }
|
|
|
|
export default function customTranslate(template, replacements) {
|
|
replacements = replacements || {};
|
|
|
|
// Translate
|
|
template = translations[template] || template;
|
|
|
|
// Replace
|
|
return template.replace(/{([^}]+)}/g, function(_, key) {
|
|
return replacements[key] || '{' + key + '}';
|
|
});
|
|
}
|
|
|