From cefe2e9ef49fff5cc5b0566a642dff4e3237ebae Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 22 Sep 2022 17:03:45 +0200 Subject: [PATCH] Add a rule to Danger to check that translation files are not modified by developers. --- docs/danger.md | 1 + tools/danger/dangerfile.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docs/danger.md b/docs/danger.md index afa3555469..34baa62e9e 100644 --- a/docs/danger.md +++ b/docs/danger.md @@ -28,6 +28,7 @@ Here are the checks that Danger does so far: - PR with change on layout should include screenshot in the description - PR which adds png file warn about the usage of vector drawables - non draft PR should have a reviewer +- files containing translations are not modified by developers ### Quality check diff --git a/tools/danger/dangerfile.js b/tools/danger/dangerfile.js index c7db52fa19..6314ec8f68 100644 --- a/tools/danger/dangerfile.js +++ b/tools/danger/dangerfile.js @@ -118,3 +118,10 @@ if (hasPngs) { if (github.requested_reviewers.users.length == 0 && !pr.draft) { warn("Please add a reviewer to your PR.") } + +// Check that translations have not been modified by developers +if (user != "RiotTranslateBot") { + if (editedFiles.some(file => file.endsWith("strings.xml") && !file.endsWith("values/strings.xml"))) { + fail("Some translation files have been edited. Only user `RiotTranslateBot` (i.e. translations coming from Weblate) is allowed to do that.\nPlease read more about translations management [in the doc](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#internationalisation).") + } +}