Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to JSON message format for UI translations #1525

Open
osma opened this issue Sep 27, 2023 · 1 comment
Open

Switch to JSON message format for UI translations #1525

osma opened this issue Sep 27, 2023 · 1 comment

Comments

@osma
Copy link
Member

osma commented Sep 27, 2023

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:

  • 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.

@osma osma added this to the 3.0 milestone Sep 27, 2023
@osma osma added this to Proposed Skosmos 3.0 issues (to do) in Skosmos 3.0 Backlog via automation Sep 27, 2023
@osma
Copy link
Member Author

osma commented Sep 27, 2023

(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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Skosmos 3.0 Backlog
  
Proposed Skosmos 3.0 issues (to do)
Development

No branches or pull requests

1 participant