Spring
This example assumes that you do not have manually created messages.properties
files yet. In case you do, you can follow this guide on creating multiple sources of localized messages and adjusting the output filenames accordingly.
Step 1 - Create a translations file
Create a mooi
directory
mkdir mooi
Within that directory, create a translations.yaml
file with your strings
# ./mooi/translations.yaml
languages: # English is assumed by default, you don't need to list it
- de
- fr
- ru
# etc.
entries:
- key: myStringId
value: Hello World
description: A message that is shown on the main screen of the app
# etc.
Step 2 - Define an output format
Within mooi
directory, create a config.yaml
file:
# ./mooi/config.yaml
formats:
- outputPath: src/main/resources/messages-{{languageCode}}.properties
format: |
{{#each translations}}
{{key}}={{{value}}}
{{/each}}
Step 3 - Run mooi
Run the following command:
npx mooi-cli translate --openAiKey {YOUR OPEN AI KEY}
You are good to go! Use the generated translations as you normally would.
Last updated