fix fallback for pluralized strings (#7480)
* fix fallback for pluralized cases Signed-off-by: Kerry Archibald <kerrya@element.io> * add test case for no pluralizer Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
@@ -85,7 +85,7 @@ export function _td(s: string): string { // eslint-disable-line @typescript-esli
|
||||
const translateWithFallback = (text: string, options?: object): { translated?: string, isFallback?: boolean } => {
|
||||
const translated = counterpart.translate(text, options);
|
||||
if (/^missing translation:/.test(translated)) {
|
||||
const fallbackTranslated = counterpart.translate(text, { ...options, fallbackLocale: FALLBACK_LOCALE });
|
||||
const fallbackTranslated = counterpart.translate(text, { ...options, locale: FALLBACK_LOCALE });
|
||||
return { translated: fallbackTranslated, isFallback: true };
|
||||
}
|
||||
return { translated };
|
||||
@@ -168,7 +168,6 @@ export function _t(text: string, variables: IVariables, tags: Tags): React.React
|
||||
export function _t(text: string, variables?: IVariables, tags?: Tags): TranslatedString {
|
||||
// The translation returns text so there's no XSS vector here (no unsafe HTML, no code execution)
|
||||
const { translated } = safeCounterpartTranslate(text, variables);
|
||||
|
||||
const substituted = substitute(translated, variables, tags);
|
||||
|
||||
return annotateStrings(substituted, text);
|
||||
|
||||
Reference in New Issue
Block a user