Lit Localize and Dynamic expressions

125 Views Asked by At

I have a screen using Lit, and we use @lit/localize for our language translation.

With our design, on this screen, the server returns a key/value pair of strings to display on the screen. The key of these pairs is somewhat dynamic, in that they can be dynamically added as a possible value, without needing to re-compile the server side that is providing these expressions.

While I realize this isn't the best case, and that also on the lit or UI side of things I have to provide the translation. In other languages where the localization is just a key/value pair to a string file, I add them. With lit/localize there is the added process of generating the translation files, and it appears to assign them a unique id.

My solution is to either do some sort of fake method where I provide msg('Some Dynamic String'). The code is never called, but it will allow me to generate the proper token in the localized files.

The other option I can think of is to have a big case statement where I am building this list and translating it that way.

Is there a better way that I am not thinking of? Has anyone solved a problem similar to this in the past, with or without lit/localize?

0

There are 0 best solutions below