mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-22 12:13:48 +01:00
Update i18n.ts
This commit is contained in:
parent
29e9c5249d
commit
bd09bf0238
@ -13,6 +13,8 @@ export default (lang, locale) => ({
|
||||
{
|
||||
pattern: /%i18n:(.+?)%/g, replacement: (_, key) => {
|
||||
let text = locale;
|
||||
|
||||
// Check the key existance
|
||||
const error = key.split('.').some(k => {
|
||||
if (text.hasOwnProperty(k)) {
|
||||
text = text[k];
|
||||
@ -21,9 +23,10 @@ export default (lang, locale) => ({
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.warn(`key '${key}' not found in '${lang}'`);
|
||||
return key;
|
||||
return key; // Fallback
|
||||
} else {
|
||||
return text.replace(/'/g, '\\\'').replace(/"/g, '\\"');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user