mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-21 17:05:39 +03:00
Merge pull request #7211 from vector-im/feature/bma/prevent_modification_of_translations
Prevent modification of translations
This commit is contained in:
commit
56189a2d5d
4 changed files with 69 additions and 7 deletions
|
@ -1,10 +1,42 @@
|
|||
# Contributing code to Matrix
|
||||
# Contributing to Element Android
|
||||
|
||||
<!--- TOC -->
|
||||
|
||||
* [Contributing code to Matrix](#contributing-code-to-matrix)
|
||||
* [Android Studio settings](#android-studio-settings)
|
||||
* [Template](#template)
|
||||
* [Compilation](#compilation)
|
||||
* [I want to help translating Element](#i-want-to-help-translating-element)
|
||||
* [I want to submit a PR to fix an issue](#i-want-to-submit-a-pr-to-fix-an-issue)
|
||||
* [Kotlin](#kotlin)
|
||||
* [Changelog](#changelog)
|
||||
* [Code quality](#code-quality)
|
||||
* [Internal tool](#internal-tool)
|
||||
* [ktlint](#ktlint)
|
||||
* [lint](#lint)
|
||||
* [Unit tests](#unit-tests)
|
||||
* [Tests](#tests)
|
||||
* [Internationalisation](#internationalisation)
|
||||
* [Adding new string](#adding-new-string)
|
||||
* [Plurals](#plurals)
|
||||
* [Editing existing strings](#editing-existing-strings)
|
||||
* [Removing existing strings](#removing-existing-strings)
|
||||
* [Renaming string ids](#renaming-string-ids)
|
||||
* [Reordering strings](#reordering-strings)
|
||||
* [Accessibility](#accessibility)
|
||||
* [Layout](#layout)
|
||||
* [Authors](#authors)
|
||||
* [Thanks](#thanks)
|
||||
|
||||
<!--- END -->
|
||||
|
||||
## Contributing code to Matrix
|
||||
|
||||
Please read https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.md
|
||||
|
||||
Element Android support can be found in this room: [![Element Android Matrix room #element-android:matrix.org](https://img.shields.io/matrix/element-android:matrix.org.svg?label=%23element-android:matrix.org&logo=matrix&server_fqdn=matrix.org)](https://matrix.to/#/#element-android:matrix.org).
|
||||
|
||||
# Specific rules for Matrix Android projects
|
||||
The rest of the document contains specific rules for Matrix Android projects
|
||||
|
||||
## Android Studio settings
|
||||
|
||||
|
@ -120,17 +152,21 @@ You should consider adding Unit tests with your PR, and also integration tests (
|
|||
|
||||
Translations are handled using an external tool: [Weblate](https://translate.element.io/projects/element-android/)
|
||||
|
||||
As a general rule, please never edit or add or remove translations to the project in a Pull Request. It can lead to merge conflict if the translations are also modified in Weblate side.
|
||||
**As a general rule, please never edit or add or remove translations to the project in a Pull Request**. It can lead to merge conflict if the translations are also modified in Weblate side. Pull Request containing change(s) on the translation files cannot be merged.
|
||||
|
||||
#### Adding new string
|
||||
|
||||
When adding new string resources, please only add new entries in the file `value/strings.xml`. Translations will be added later by the community of translators using Weblate.
|
||||
When adding new string resources, please only add new entries in the file `values/strings.xml` ([this file](./library/ui-strings/src/main/res/values/strings.xml)). Translations will be added later by the community of translators using Weblate.
|
||||
|
||||
The file `value/strings.xml` must only contain American English (U. S. English) values, as this is the default language of the Android operating system. So for instance, please use "color" instead of "colour". Element Android will still use the language set on the system by the user, like any other Android applications which provide translations. The system language can be any other English language variants, or any other languages. Note that this is also possible to override the system language using the Element Android in-app language settings.
|
||||
The file `values/strings.xml` must only contain American English (U. S. English) values, as this is the default language of the Android operating system. So for instance, please use "color" instead of "colour". Element Android will still use the language set on the system by the user, like any other Android applications which provide translations. The system language can be any other English language variants, or any other languages. Note that this is also possible to override the system language using the Element Android in-app language settings.
|
||||
|
||||
New strings can be added anywhere in the file `value/strings.xml`, not necessarily at the end of the file. Generally, it's even better to add the new strings in some dedicated section per feature, and not at the end of the file, to avoid merge conflict between 2 PR adding strings at the end of the same file.
|
||||
New strings can be added anywhere in the file `values/strings.xml`, not necessarily at the end of the file. Generally, it's even better to add the new strings in some dedicated section per feature, and not at the end of the file, to avoid merge conflict between 2 PR adding strings at the end of the same file.
|
||||
|
||||
Do not hesitate to use plurals when appropriate.
|
||||
##### Plurals
|
||||
|
||||
Please use `plurals` resources when appropriate, and note that some languages have specific rules for `plurals`, so even if the string will always be at the plural form for English, please always create a `plurals` resource.
|
||||
|
||||
Specific plural forms can be found [here](https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_plural_rules.html).
|
||||
|
||||
#### Editing existing strings
|
||||
|
||||
|
@ -150,6 +186,23 @@ And add `tools:ignore="UnusedResources"` to the string, to let lint ignore that
|
|||
|
||||
The string will be removed during the next sync with Weblate.
|
||||
|
||||
#### Renaming string ids
|
||||
|
||||
This is possible to rename ids of the String resources, but since translation files cannot be edited, add TODO in the main strings.xml file above the strings you want to rename.
|
||||
|
||||
```xml
|
||||
<!-- TODO Rename id to put_new_id_here -->
|
||||
<string name="current_id">Hello Matrix world!</string>
|
||||
```
|
||||
|
||||
The string id(s) will be renamed during the next Weblate sync.
|
||||
|
||||
#### Reordering strings
|
||||
|
||||
To group strings per feature, or for any other reasons, it is possible to reorder string resources, but only in the [main strings.xml file](./library/ui-strings/src/main/res/values/strings.xml). ). We do not mind about ordering in the translation files, and anyway this is forbidden to edit manually the translation files.
|
||||
|
||||
It is also possible to add empty lines between string resources, and to add XML comments. Please note that the XML comment just above a String resource will also appear on Weblate and be visible to the translators.
|
||||
|
||||
### Accessibility
|
||||
|
||||
Please consider accessibility as an important point. As a minimum requirement, in layout XML files please use attributes such as `android:contentDescription` and `android:importantForAccessibility`, and test with a screen reader if it's working well. You can add new string resources, dedicated to accessibility, in this case, please prefix theirs id with `a11y_`.
|
||||
|
|
1
changelog.d/7211.misc
Normal file
1
changelog.d/7211.misc
Normal file
|
@ -0,0 +1 @@
|
|||
CI: Prevent modification of translations by developer.
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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).")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue