Skip to content

Commit

Permalink
Improve devdocs for localization (#11356)
Browse files Browse the repository at this point in the history
* Improve devdocs for localization

* Fixup

* Add file hint
  • Loading branch information
koppor authored Jun 4, 2024
1 parent 109600b commit dba4d0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions docs/code-howtos/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ The actual usage might look like:
Localization.menuTitle("Used for Menus only");
```

General hints:
## General hints

* Use the String you want to localize directly, do not use members or local variables: `Localization.lang("Translate me");` instead of `Localization.lang(someVariable)` (possibly in the form `someVariable = Localization.lang("Translate me")`
* Use `%x`-variables where appropriate: `Localization.lang("Exported %0 entries.", number)` instead of `Localization.lang("Exported ") + number + Localization.lang(" entries.");`
* Use a full stop/period (".") to end full sentences

The tests check whether translation strings appear correctly in the resource bundles.
## Checking for correctness

The tests in `org.jabref.logic.l10n.LocalizationConsistencyTest` check whether translation strings appear correctly in the resource bundles.

## Adding a new key

1. Add new `Localization.lang("KEY")` to Java file. Run the `org.jabref.logic.LocalizationConsistencyTest`.
2. Tests fail. In the test output a snippet is generated which must be added to the English translation file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void findMissingLocalizationKeys() throws IOException {
"""
DETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH LANGUAGE FILE
PASTE THESE INTO THE ENGLISH LANGUAGE FILE
PASTE THESE INTO THE ENGLISH LANGUAGE FILE "JabRef_en.properties"
""",
"\n\n")));
Expand All @@ -149,7 +149,7 @@ void findObsoleteLocalizationKeys() throws IOException {
"""
1. CHECK IF THE KEY IS REALLY NOT USED ANYMORE
2. REMOVE THESE FROM THE ENGLISH LANGUAGE FILE
2. REMOVE THESE FROM THE ENGLISH LANGUAGE FILE "JabRef_en.properties"
"""))
);
Expand Down

0 comments on commit dba4d0c

Please sign in to comment.