From fb8d62457b2f16fbf4d89cb17787ece4960f1331 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Mon, 21 Oct 2024 22:50:06 +0800 Subject: [PATCH] docs: document that we need to translate user-facing texts --- .github/PULL_REQUEST_TEMPLATE.md | 3 ++- CONTRIBUTING.md | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8b45226f..a75713ef 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,9 +3,10 @@ ## Standards checklist -- [ ] The PR title is descriptive. +- [ ] The PR title is descriptive - [ ] I have read `CONTRIBUTING.md` - [ ] *Optional:* I have tested the code myself +- [ ] If this PR introduces new user-facing messages they are translated ## For new steps diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7f1f6d82..2ee1ec1a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -129,6 +129,24 @@ $ cargo test Don't worry about other platforms, we have most of them covered in our CI. +## I18n + +If your PR introduces user-facing messages, we need to ensure they are translated. +Please add the translations to [`locales/app.yml`][app_yml]. For simple messages +without arguments (e.g., "hello world"), we can simply translate them according +(Tip: ChatGPT or similar LLMs is good at translation). If a message contains +arguments, e.g., "hello ", please follow this convention: + +```yml +"hello {name}": # key + en: "hello %{name}" # translation +``` + +Arguments in the key should be in format `{argument_name}`, and they will have +a preceeding `%` when used in translations. + +[app_yml]: https://github.com/topgrade-rs/topgrade/blob/main/locales/app.yml + ## Some tips 1. Locale