Fixed: Replacing 'appName' translation token

pull/6145/head
Stevie Robinson 1 year ago committed by GitHub
parent 8c3a0ebaba
commit 2e51b8792d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,15 +25,13 @@ export async function fetchTranslations(): Promise<boolean> {
export default function translate( export default function translate(
key: string, key: string,
tokens: Record<string, string | number | boolean> = { appName: 'Sonarr' } tokens: Record<string, string | number | boolean> = {}
) { ) {
const translation = translations[key] || key; const translation = translations[key] || key;
if (tokens) { tokens.appName = 'Sonarr';
return translation.replace(/\{([a-z0-9]+?)\}/gi, (match, tokenMatch) => return translation.replace(/\{([a-z0-9]+?)\}/gi, (match, tokenMatch) =>
String(tokens[tokenMatch] ?? match) String(tokens[tokenMatch] ?? match)
); );
}
return translation;
} }

Loading…
Cancel
Save