From dba4d0cc57468b919de15bee7f4474202c830855 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Tue, 4 Jun 2024 16:09:17 +0200 Subject: [PATCH] Improve devdocs for localization (#11356) * Improve devdocs for localization * Fixup * Add file hint --- docs/code-howtos/localization.md | 8 ++++++-- .../jabref/logic/l10n/LocalizationConsistencyTest.java | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/code-howtos/localization.md b/docs/code-howtos/localization.md index f2da0d5950e..d1f6f39b0f0 100644 --- a/docs/code-howtos/localization.md +++ b/docs/code-howtos/localization.md @@ -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. diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java b/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java index 7781be1c796..718a3f5afbc 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java @@ -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"))); @@ -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" """)) );