Appsilon / shiny.i18n

Shiny applications internationalization made easy
https://appsilon.github.io/shiny.i18n/
Other
169 stars 38 forks source link

How using Shiny.i18n for translation of modal dialogue of module 2 which rendered within the server of module 1 #55

Closed mehdihadi closed 3 years ago

mehdihadi commented 3 years ago

I want to translate modal dialogues in my modularized shiny app. As I presented in my reproducible example here, in the first module (register) I have no problem as registerUI() rendered the first modal dialogue and translation works well. But my problem is with the UI of module 2 (M2UI) which this function itself has been called within the server of module 1 (register) to return the second modal dialogue. But i18n probably not detected and translation not works on the displayed new modal. Any suggestions why this happens? thanks in advance.

dokato commented 3 years ago

hey @mehdihadi , could you test if this solution from this thread works for you: https://github.com/Appsilon/shiny.i18n/issues/48#issuecomment-730323324 Basically, it's related to how shiny handles sessions within the modules.

mehdihadi commented 3 years ago

Dear @dokato thanks for your comment, I tried #48 (comment) but I think this issue is not similar my one. My problem is about the translation of nested modal (the modal rendered in another modal). By the way, my problem is not resolved and I decides to use "if " for language selection. thanks anyway...

dokato commented 3 years ago

Ok, could you show then your minimal example, where you introduced passing a global session to your Shiny module that renders a modal?

mehdihadi commented 3 years ago

Hi @dokato my completely reproducible example is here. Simply when you click on the "test" button, the first modal dialogue displayed where translation is OK. But when you click the "submit" button (in the first modal) then in the second displayed modal translation not works!!!

dokato commented 3 years ago

Hi @mehdihadi in this example from SOF, there is no global session in your modal as I suggested before. Please try passing global session (eg. session from the main server of your app) there.