mistercrunch commented on code in PR #34118:
URL: https://github.com/apache/superset/pull/34118#discussion_r2201837778
##########
superset-frontend/packages/superset-ui-core/src/translation/Translator.ts:
##########
@@ -86,20 +86,35 @@ export default class Translator {
}
translate(input: string, ...args: unknown[]): string {
- return this.i18n.translate(input).fetch(...args);
+ try {
+ return this.i18n.translate(input).fetch(...args);
+ } catch (err) {
+ logging.warn(`Translation failed for key "${input}" with args:`, args);
+ logging.warn(err);
+ return input;
+ }
}
translateWithNumber(key: string, ...args: unknown[]): string {
- const [plural, num, ...rest] = args;
- if (typeof plural === 'number') {
+ try {
+ const [plural, num, ...rest] = args;
+ if (typeof plural === 'number') {
+ return this.i18n
+ .translate(key)
+ .ifPlural(plural, key)
+ .fetch(plural, num, ...args);
Review Comment:
I think i'm going to roll with #1 . I'm guessing it's ok to rely on hard
coded pure t like `{num} dashboard(s) were saved.` instead of hoping the
gettext pluralization to work ...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]