Using nested translation variables
We want to create some complex notification massages that require to have nested translated messages/variables.
We want to have two translations of same message:
"{{firstName}} has changed the status to {{newStatus}}." (English)
"{{firstName}} hat den Status auf {{newStatus}} geändert." (German)
And here we have a problem of properly setting text for "newStatus".
I haven't found a way to store possible statuses as different texts in same i18n file and to reference them in any way
Setting such in-app text
Results in error "Failed to extract variables"
Without putting
newStatus
variable - everything works as expected.
Is it possible to somehow use i18n messages in another message? Or what would be your advice regarding such messages?10 Replies
Hey @Dima_hat 👋, let me add here @Pawan Jain to help us 🙂
Hi @Dima_hat
You could try something like this:
In your conversations translation file:
and then in the editor you would use it like this:
is that what you were looking for?
Hey hey,
Thanks for reply.
Unfortunately not exactly.
For statuses it's also several different translated strings that we want to store in novu, so we need to provide which status exactly should be taken from the translation file
And which one of two statuses to take - we need to provide also as payload variable
Is that possible to perform somehow?
in editor:
and in pauload you would add
How is that @Dima_hat ? 🙂
Thanks! That's already helps a lot!
Just trying to understand regarding possibilities
Is it possible to have two different separate contexts?
That in translation file we have
And to somehow pack both different
busy | progress
and formal | informal
contexts together
Looks like it's impossible with such approach
And there can be only one context?From what I can tell multiple contexts are not really supported by i18next. But, you can dig a bit deeper if they have a work around. Maybe this example could be a good lead (involving a var + context )
We are using i18next, so what most of what they allow will work in novu
except maybe some formats, that might need some adjusting
Thanks for the docs, will definitely have a look
One last question - it's impossible to pass a variable on which string from the translations file should be taken
So having in editor:
doesn't work 😦 .
Probably I'm getting the templating wrong or it's really not possible
It will also provide possibility to decide what message should be taken by the payload, but without exploiting contexts
@Dima_hat, you just advanced to level 3!