File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -78,12 +78,16 @@ class StringProvider {
7878 if ( Array . isArray ( args ) ) // it's better to cut the string under multiple IDs to avoid any confusion during decision of the plural category
7979 throw new Error ( `Passing multiple arguments to a plural string is not supported: ${ str } ` ) ;
8080
81- const pluralCategory = pluralRules [ locale ] . select ( args )
82- const loadedPluralForm = loaded [ pluralCategory ] ;
8381
84- if ( ! loadedPluralForm ) // Translator probably forgot to define the requested plural
85- return this . _insertArguments ( locales [ this . defaultLocale ] [ str . trim ( ) ] [ pluralRules [ this . defaultLocale ] . select ( args ) ] ,
86- args ) ; // => return fallback language
82+ let pluralCategory = pluralRules [ locale ] . select ( args )
83+ let loadedPluralForm = loaded [ pluralCategory ] ;
84+ if ( loadedPluralForm === null || loadedPluralForm === undefined )
85+ {
86+ // Translator probably forgot to define the requested plural
87+ pluralCategory = pluralRules [ this . defaultLocale ] . select ( args ) ; // return fallback language instead
88+ try { loadedPluralForm = locales [ this . defaultLocale ] [ str . trim ( ) ] [ pluralCategory ] || str ; }
89+ catch { loadedPluralForm = str ; } // return input ID if default language do not define it either
90+ }
8791
8892 return this . _insertArguments ( loadedPluralForm , args ) ;
8993 } ;
You can’t perform that action at this time.
0 commit comments