Migrate more strings to translation keys (#11651)

This commit is contained in:
Michael Telatynski 2023-09-22 16:39:40 +01:00 committed by GitHub
parent 560449676b
commit f4d056fd38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
127 changed files with 8916 additions and 8272 deletions

View file

@ -78,8 +78,7 @@ export class UserFriendlyError extends Error {
const errorOptions = {
cause: substitutionVariablesAndCause?.cause,
};
// Prevent "Could not find /%\(cause\)s/g in x" logs to the console by removing
// it from the list
// Prevent "Could not find /%\(cause\)s/g in x" logs to the console by removing it from the list
const substitutionVariables = { ...substitutionVariablesAndCause };
delete substitutionVariables["cause"];
@ -247,6 +246,14 @@ export function _t(text: TranslationKey, variables?: IVariables, tags?: Tags): T
return annotateStrings(substituted, text);
}
/**
* Utility function to look up a string by its translation key without resolving variables & tags
* @param key - the translation key to return the value for
*/
export function lookupString(key: TranslationKey): string {
return safeCounterpartTranslate(key, {}).translated;
}
/*
* Wraps normal _t function and adds atttribution for translations that used a fallback locale
* Wraps translations that fell back from active locale to fallback locale with a `<span lang=<fallback locale>>`
@ -318,10 +325,10 @@ export function substitute(text: string, variables?: IVariables, tags?: Tags): s
return result;
}
/*
/**
* Replace parts of a text using regular expressions
* @param {string} text The text on which to perform substitutions
* @param {object} mapping A mapping from regular expressions in string form to replacement string or a
* @param text - The text on which to perform substitutions
* @param mapping - A mapping from regular expressions in string form to replacement string or a
* function which will receive as the argument the capture groups defined in the regexp. E.g.
* { 'Hello (.?) World': (sub) => sub.toUpperCase() }
*