From 7cffd25ce25a23c953969ed3591c91595d400f70 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Tue, 4 Jun 2024 15:41:45 +0200 Subject: [PATCH 1/3] Improve devdocs for localization --- docs/code-howtos/localization.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/code-howtos/localization.md b/docs/code-howtos/localization.md index f2da0d5950e..fa1fa2ea61b 100644 --- a/docs/code-howtos/localization.md +++ b/docs/code-howtos/localization.md @@ -27,13 +27,15 @@ 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 completeness (and more) + +The tests in `org.jabref.logic.l10n.LocalizationConsistencyTest` check whether translation strings appear correctly in the resource bundles. 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. From 08af3a2f76995e622c7fe4819cb06a9ac516329a Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Tue, 4 Jun 2024 15:42:49 +0200 Subject: [PATCH 2/3] Fixup --- docs/code-howtos/localization.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/code-howtos/localization.md b/docs/code-howtos/localization.md index fa1fa2ea61b..d1f6f39b0f0 100644 --- a/docs/code-howtos/localization.md +++ b/docs/code-howtos/localization.md @@ -33,10 +33,12 @@ The actual usage might look like: * 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 -## Checking for completeness (and more) +## 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. 3. Add snippet to English translation file located at `src/main/resources/l10n/JabRef_en.properties` From c5d43e0549424ccb1c574c84c4747d8efd151d31 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Tue, 4 Jun 2024 15:45:45 +0200 Subject: [PATCH 3/3] Add file hint --- .../org/jabref/logic/l10n/LocalizationConsistencyTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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" """)) );