ory / kratos

The most scalable and customizable identity server on the market. Replace your Homegrown, Auth0, Okta, Firebase with better UX and DX. Has all the tablestakes: Passkeys, Social Sign In, Multi-Factor Auth, SMS, SAML, TOTP, and more. Written in Go, cloud native, headless, API-first. Available as a service on Ory Network and for self-hosters.
https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=kratos
Apache License 2.0
11.24k stars 963 forks source link

Provide machine-readable list of messages for translation #2498

Closed woylie closed 2 years ago

woylie commented 2 years ago

Preflight checklist

Describe your problem

To make translations of error messages easier, it would be great to have a machine-readable list of messages in use.

Describe your ideal solution

As discussed in #2460, a solution might be to repurpose the writeMessages to also return a machine-readable format.

https://github.com/ory/kratos/blob/b682689dd781d52d164b0c6edaf77ab15c9ef154/cmd/clidoc/main.go#L157

JSON would be fine. Not sure what to do with the output.

  1. add it to the docs
  2. add a make task that generates a JSON file
  3. add a CLI command that returns the JSON
  4. add an API route that returns the JSON

Any would do, but with 3 or 4, it would be easier to automate the update of the translation source files in an application.

Please let me know what you think.

Workarounds or alternatives

Copying the messages manually from the docs and turning them into a JSON document. 🥴

Version

0.10.1

Additional Context

No response

woylie commented 2 years ago

For some more context, I run Kratos with docker compose side-by-side with the Elixir application I'm developing. Solution 3 or 4 would allow me to:

  1. add a mix task to my application to fetch the messages.json and put it into some import folder
  2. add a module that reads that json file at compile time and calls Gettext.gettext_noop/1 on all messages to mark them for translation
  3. run mix gettext.extract --merge to update all .pot and .po files
aeneasr commented 2 years ago

Hey, it is a great idea to have this as a JSON file. As you pointed out, I think modifying the CLI helper to also output it as a JSON should be pretty straight forward. Would you be up for a PR for this? :)

woylie commented 2 years ago

Yes, it's on my to do list, I'll get to this soon.