Using built-in dialog box for notifications

meet

#1

Hello,

I’d like to display custom warning messages by triggering Jitsi-Meet built-in dialog box.
I found the function below but I believe that descriptionKey and titleKey values should be added to lang/main.json.

APP.UI.messageHandler.showWarning({descriptionKey:"Warning Description",titleKey:"Test"})
image

is there any way to show this box without “main :” prefix in each string and without editing language files ?

Thanks.


#2

Hello,

I added a custom string manually in lang/main.json file.

~$ grep myCustomTitle /usr/share/jitsi-meet/lang/main.json 
    "myCustomTitle":"My custom title",

then I called it with the command below

APP.UI.messageHandler.showWarning({titleKey:'myCustomTitle', descriptionKey:""});

and Here’s the result
image

My Jitsi’s current language is French but normally it will display myCustomTitle from main.json file if it doesn’t find it in main-fr.json, right ?

any idea why it’s not working ?


#3

The notification component is set up to always take in translation strings and raw strings. This is where the notification content is put in: https://github.com/jitsi/jitsi-meet/blob/d4c08406594f20be6327a144c9f697d7b01ceeaf/react/features/notifications/components/AbstractNotification.js#L128 This is where the notification content is put in: https://github.com/jitsi/jitsi-meet/blob/d4c08406594f20be6327a144c9f697d7b01ceeaf/react/features/notifications/components/Notification.web.js#L67

Notice how a raw title can already be set by passing in { title, description } instead of { titleKey, descriptionKey }. That’s at least how I’m reading it.

And yes, there is a fallback language if the current language does not have the translation. https://github.com/jitsi/jitsi-meet/blob/d4c08406594f20be6327a144c9f697d7b01ceeaf/react/features/base/i18n/i18next.js#L44. (Although, I think there’s a potential bug there because the fallback language is fetched by converting the object LANGUAGES_RESOURCES to an array, but object key order is not guaranteed. It probably works by coincidence because browsers are generally nice about converting objects into arrays based on order of addition…)

As for why it’s not working for you, I don’t know. Did you nest the new key within another object in main.json?


#4

Thanks, I will use title and description instead of titleKey and descriptionKey
APP.UI.messageHandler.showWarning({title:'My Title', description:"My Message"});

Yeah It doesn’t work, maybe there’s a bug as you said…

Thank you for your help.