We are currently using traditional gettext .po files for storing translated messages. For Skosmos 3, it would make sense to switch to JSON as the message file format because the same files could then be used both by the backend and the frontend.
The Skosmos 3 backend now uses Symfony Translations for handling translated messages in PHP code and Twig templates. For the frontend components implemented using Vue there is currently no mechanism for UI translations but we need one - see #1523.
Vue i18n, the most likely candidate for handling the translations in Vue components, reads the translated messages from a JavaScript object usually called messages which contains the translations for all languages - see example from the new Finto AI.
If we stored the messages in simple JSON files that are accessible both to the backend and frontend, the exact same files could be used both by Symfony Translations and (after merging the separate languages into a single object) Vue i18n. There would be no need to pass the necessary translations from the backend to the frontend.
What has to be done to make this happen:
convert resource/translations/*.po to JSON format
switch Symfony Translations so it uses JsonFileLoader
A possible complication is how this would affect Transifex. I haven't checked whether it's able to read and write JSON files. (We could also consider switching to another translation platform - Symfony supports Crowdin, Loco and Localise - but that's beyond the scope of this issue).
Who are the users that would benefit from the enhancement and how?
Skosmos developers; indirectly all users as well
What new functionalities would the enhancement make possible?
It would simplify implementing Vue component UI translations (#1523)
Why is the enhancement important?
I think this is a good moment to switch formats. There is almost nothing that requires us to use .po files anymore, now that we've switched away from traditional gettext.
(We could also consider switching to another translation platform - Symfony supports Crowdin, Loco and Localise - but that's beyond the scope of this issue).
I opened a separate issue #1527 about switching translation provider.
Description of the enhancement
We are currently using traditional gettext
.po
files for storing translated messages. For Skosmos 3, it would make sense to switch to JSON as the message file format because the same files could then be used both by the backend and the frontend.The Skosmos 3 backend now uses Symfony Translations for handling translated messages in PHP code and Twig templates. For the frontend components implemented using Vue there is currently no mechanism for UI translations but we need one - see #1523.
Symfony Translations supports many message formats, among them a very simple JSON key-value format - see JSON loader implementation and example message file from the test suite. The translations for each language has to be stored in a separate JSON file.
Vue i18n, the most likely candidate for handling the translations in Vue components, reads the translated messages from a JavaScript object usually called
messages
which contains the translations for all languages - see example from the new Finto AI.If we stored the messages in simple JSON files that are accessible both to the backend and frontend, the exact same files could be used both by Symfony Translations and (after merging the separate languages into a single object) Vue i18n. There would be no need to pass the necessary translations from the backend to the frontend.
What has to be done to make this happen:
resource/translations/*.po
to JSON formatA possible complication is how this would affect Transifex. I haven't checked whether it's able to read and write JSON files. (We could also consider switching to another translation platform - Symfony supports Crowdin, Loco and Localise - but that's beyond the scope of this issue).
Who are the users that would benefit from the enhancement and how?
Skosmos developers; indirectly all users as well
What new functionalities would the enhancement make possible?
It would simplify implementing Vue component UI translations (#1523)
Why is the enhancement important?
I think this is a good moment to switch formats. There is almost nothing that requires us to use .po files anymore, now that we've switched away from traditional gettext.