From 746b03660ebf4c47d9cecdfff717c47c53494007 Mon Sep 17 00:00:00 2001 From: WVam <83856938+WVam@users.noreply.github.com> Date: Sat, 25 Feb 2023 16:01:27 +0100 Subject: [PATCH 01/11] Update en_us.json --- Xplat/src/main/resources/assets/patchouli/lang/en_us.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xplat/src/main/resources/assets/patchouli/lang/en_us.json b/Xplat/src/main/resources/assets/patchouli/lang/en_us.json index b9475fc4..c92d6d4a 100644 --- a/Xplat/src/main/resources/assets/patchouli/lang/en_us.json +++ b/Xplat/src/main/resources/assets/patchouli/lang/en_us.json @@ -63,7 +63,7 @@ "patchouli.gui.lexicon.loading_error_hover": "(Hover for info)", "patchouli.gui.lexicon.loading_error_log": "Check your log for more", "patchouli.gui.lexicon.dev_edition": "Writer's", - "patchouli.gui.lexicon.edition_str": "%s Edition", + "patchouli.gui.lexicon.edition_str": "Edition #%s", "patchouli.gui.lexicon.added_by": "Added by %s", "patchouli.gui.lexicon.sneak": "Sneak to view", "patchouli.gui.lexicon.view": "View entry", From 8e21073bb917db91a94a193176585d5ed6002280 Mon Sep 17 00:00:00 2001 From: WVam <83856938+WVam@users.noreply.github.com> Date: Thu, 2 Mar 2023 23:44:57 +0100 Subject: [PATCH 02/11] Fixed untranslatable ordinals --- .../vazkii/patchouli/common/book/Book.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java index a84a2302..08722416 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java @@ -257,7 +257,7 @@ public Style getFontStyle() { } public MutableComponent getSubtitle() { - Component editionStr; + Component edition; try { int ver = Integer.parseInt(version); @@ -265,12 +265,12 @@ public MutableComponent getSubtitle() { return Component.translatable(subtitle); } - editionStr = Component.literal(numberToOrdinal(ver)); + editionStr = numberToOrdinal(ver); } catch (NumberFormatException e) { - editionStr = Component.translatable("patchouli.gui.lexicon.dev_edition"); + return Component.translatable("patchouli.gui.lexicon.dev_edition"); } - return Component.translatable("patchouli.gui.lexicon.edition_str", editionStr); + return Component.translatable("patchouli.gui.lexicon.edition_str", edition); } public BookIcon getIcon() { @@ -281,8 +281,21 @@ public BookIcon getIcon() { } } - private static String numberToOrdinal(int i) { - return i % 100 == 11 || i % 100 == 12 || i % 100 == 13 ? i + "th" : i + ORDINAL_SUFFIXES[i % 10]; + private static Component numberToOrdinal(int i) { + int units = i % 10; + int tens = i % 100 - units; + String base = "patchouli.gui.lexicon.edition_str.ord"; + if (i%1000 >= 100 && tens == 0) {tens = 100;} + i = Integer.toString(i); + units = Integer.toString(units); + tens = Integer.toString(tens); + return Component.translatable(String.join(".", base, tens), i + Component.translatable(String.join(".", base, units), i), + Component.translatable(String.join(".", base, tens, units), i, + Component.translatable(String.join(".", base, units), i) + ) + ) + } public BookContents getContents() { From bd960b5ed4d29fdc1b4bf87e51ec0c1cccdb30b2 Mon Sep 17 00:00:00 2001 From: WVam <83856938+WVam@users.noreply.github.com> Date: Thu, 2 Mar 2023 23:47:28 +0100 Subject: [PATCH 03/11] Semicolon --- Xplat/src/main/java/vazkii/patchouli/common/book/Book.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java index 08722416..81eee9fd 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java @@ -294,7 +294,7 @@ private static Component numberToOrdinal(int i) { Component.translatable(String.join(".", base, tens, units), i, Component.translatable(String.join(".", base, units), i) ) - ) + ); } From 0b615eaf05654b42c93d8adeef37df6068d01c12 Mon Sep 17 00:00:00 2001 From: WVam <83856938+WVam@users.noreply.github.com> Date: Thu, 2 Mar 2023 23:49:22 +0100 Subject: [PATCH 04/11] Tens 0 = 00 --- Xplat/src/main/java/vazkii/patchouli/common/book/Book.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java index 81eee9fd..e58cb321 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java @@ -288,7 +288,7 @@ private static Component numberToOrdinal(int i) { if (i%1000 >= 100 && tens == 0) {tens = 100;} i = Integer.toString(i); units = Integer.toString(units); - tens = Integer.toString(tens); + tens = tens == 0 ? "00" : Integer.toString(tens); return Component.translatable(String.join(".", base, tens), i Component.translatable(String.join(".", base, units), i), Component.translatable(String.join(".", base, tens, units), i, From b1a7851020ffffac991c0b6a00b7a99e297b016b Mon Sep 17 00:00:00 2001 From: WVam <83856938+WVam@users.noreply.github.com> Date: Fri, 3 Mar 2023 00:13:35 +0100 Subject: [PATCH 05/11] Commented --- .../vazkii/patchouli/common/book/Book.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java index e58cb321..f60dddb7 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java @@ -285,15 +285,27 @@ private static Component numberToOrdinal(int i) { int units = i % 10; int tens = i % 100 - units; String base = "patchouli.gui.lexicon.edition_str.ord"; - if (i%1000 >= 100 && tens == 0) {tens = 100;} + if (i % 1000 >= 100 && tens == 0) {tens = 100;} i = Integer.toString(i); units = Integer.toString(units); tens = tens == 0 ? "00" : Integer.toString(tens); + /* + The translation key is first picked based on the number's tens. + - If the translation is "%1$s", then that suffix will be used for all numbers with those tens. + - If the translation is "%2$s", then for all the numbers with those tens + it will pick a suffix based on the units alone (the translation of .). + - If the translation is "%3$s", then for all the numbers with those tens + it will pick a translation based on both units AND tens. This translation can be: + - "%1$s" (default tens suffix) + - "%2$s" (default units suffix) + - "%3$s" (a special suffix) + */ return Component.translatable(String.join(".", base, tens), i Component.translatable(String.join(".", base, units), i), - Component.translatable(String.join(".", base, tens, units), i, - Component.translatable(String.join(".", base, units), i) - ) + Component.translatable(String.join(".", base, tens, units), + Component.translatable(String.join(".", base, tens), i), + Component.translatable(String.join(".", base, units), i), + i) ); } From 0e56356fa7068c70d19b7c0df27f733a3e9df0a4 Mon Sep 17 00:00:00 2001 From: WVam <83856938+WVam@users.noreply.github.com> Date: Fri, 3 Mar 2023 00:14:14 +0100 Subject: [PATCH 06/11] English ordinals --- .../assets/patchouli/lang/en_us.json | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Xplat/src/main/resources/assets/patchouli/lang/en_us.json b/Xplat/src/main/resources/assets/patchouli/lang/en_us.json index c92d6d4a..7db0786d 100644 --- a/Xplat/src/main/resources/assets/patchouli/lang/en_us.json +++ b/Xplat/src/main/resources/assets/patchouli/lang/en_us.json @@ -62,8 +62,8 @@ "patchouli.gui.lexicon.loading_error": "Loading error!", "patchouli.gui.lexicon.loading_error_hover": "(Hover for info)", "patchouli.gui.lexicon.loading_error_log": "Check your log for more", - "patchouli.gui.lexicon.dev_edition": "Writer's", - "patchouli.gui.lexicon.edition_str": "Edition #%s", + "patchouli.gui.lexicon.dev_edition": "Writer's Edition", + "patchouli.gui.lexicon.edition_str": "%s Edition", "patchouli.gui.lexicon.added_by": "Added by %s", "patchouli.gui.lexicon.sneak": "Sneak to view", "patchouli.gui.lexicon.view": "View entry", @@ -75,6 +75,28 @@ "patchouli.gui.lexicon.mark_complete": "Mark Complete", "patchouli.gui.lexicon.mark_incomplete": "Mark Incomplete", + "patchouli.gui.lexicon.edition_str.ord.0":"%1$sth", + "patchouli.gui.lexicon.edition_str.ord.1":"%1$sst", + "patchouli.gui.lexicon.edition_str.ord.2":"%1$snd", + "patchouli.gui.lexicon.edition_str.ord.3":"%1$srd", + "patchouli.gui.lexicon.edition_str.ord.4":"%1$sth", + "patchouli.gui.lexicon.edition_str.ord.5":"%1$sth", + "patchouli.gui.lexicon.edition_str.ord.6":"%1$sth", + "patchouli.gui.lexicon.edition_str.ord.7":"%1$sth", + "patchouli.gui.lexicon.edition_str.ord.8":"%1$sth", + "patchouli.gui.lexicon.edition_str.ord.9":"%1$sth", + "patchouli.gui.lexicon.edition_str.ord.00":"%2$s", + "patchouli.gui.lexicon.edition_str.ord.10":"%1$sth", + "patchouli.gui.lexicon.edition_str.ord.20":"%2$s", + "patchouli.gui.lexicon.edition_str.ord.30":"%2$s", + "patchouli.gui.lexicon.edition_str.ord.40":"%2$s", + "patchouli.gui.lexicon.edition_str.ord.50":"%2$s", + "patchouli.gui.lexicon.edition_str.ord.60":"%2$s", + "patchouli.gui.lexicon.edition_str.ord.70":"%2$s", + "patchouli.gui.lexicon.edition_str.ord.80":"%2$s", + "patchouli.gui.lexicon.edition_str.ord.90":"%2$s", + "patchouli.gui.lexicon.edition_str.ord.100":"%2$s", + "patchouli.gui.lexicon.button.prev_page": "Previous", "patchouli.gui.lexicon.button.next_page": "Next", "patchouli.gui.lexicon.button.back": "Back", From c6d795551e1c2cf3d707f7178bc43fe313a8b49a Mon Sep 17 00:00:00 2001 From: WVam <83856938+WVam@users.noreply.github.com> Date: Fri, 3 Mar 2023 11:31:50 +0100 Subject: [PATCH 07/11] Added units distinction & more Added special tens category for values less than 0 Commented on units distinction. Made it so that edition values below 0 return Writer's Edition. --- .../vazkii/patchouli/common/book/Book.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java index f60dddb7..23298e39 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java @@ -263,6 +263,8 @@ public MutableComponent getSubtitle() { int ver = Integer.parseInt(version); if (ver == 0) { return Component.translatable(subtitle); + } else if (ver < 0) { + return Component.translatable("patchouli.gui.lexicon.dev_edition"); } editionStr = numberToOrdinal(ver); @@ -286,9 +288,9 @@ private static Component numberToOrdinal(int i) { int tens = i % 100 - units; String base = "patchouli.gui.lexicon.edition_str.ord"; if (i % 1000 >= 100 && tens == 0) {tens = 100;} - i = Integer.toString(i); - units = Integer.toString(units); - tens = tens == 0 ? "00" : Integer.toString(tens); + String i_str = Integer.toString(i); + String units_str = Integer.toString(units); + String tens_str = tens == 0 ? (i < 10 ? "uu" : "00") : Integer.toString(tens); /* The translation key is first picked based on the number's tens. - If the translation is "%1$s", then that suffix will be used for all numbers with those tens. @@ -299,15 +301,18 @@ it will pick a suffix based on the units alone (the translation of ." (a special suffix) + If the tens of a number are equal to 0, 'tens' can have three possible values: + - "uu" if the number is less than 10 (1, 2, 3, ...) + - "00" if the number is greater than 10 and number's hundreds are equal to 0 (1001, 2002, 3003, ...) + - "100" if the number's hundreds are not equal to 0 (101, 202, 3303, ...) */ - return Component.translatable(String.join(".", base, tens), i - Component.translatable(String.join(".", base, units), i), - Component.translatable(String.join(".", base, tens, units), - Component.translatable(String.join(".", base, tens), i), - Component.translatable(String.join(".", base, units), i), - i) + return Component.translatable(String.join(".", base, tens_str), i_str + Component.translatable(String.join(".", base, units_str), i_str), + Component.translatable(String.join(".", base, tens_str, units_str), + Component.translatable(String.join(".", base, tens_str), i_str), + Component.translatable(String.join(".", base, units_str), i_str), + i_str) ); - } public BookContents getContents() { From b6ca10c6738533cb45fbc462c045c529259512e5 Mon Sep 17 00:00:00 2001 From: WVam <83856938+WVam@users.noreply.github.com> Date: Fri, 3 Mar 2023 11:33:22 +0100 Subject: [PATCH 08/11] Updated to match recent changes --- Xplat/src/main/resources/assets/patchouli/lang/en_us.json | 1 + 1 file changed, 1 insertion(+) diff --git a/Xplat/src/main/resources/assets/patchouli/lang/en_us.json b/Xplat/src/main/resources/assets/patchouli/lang/en_us.json index 7db0786d..77fc9aa6 100644 --- a/Xplat/src/main/resources/assets/patchouli/lang/en_us.json +++ b/Xplat/src/main/resources/assets/patchouli/lang/en_us.json @@ -85,6 +85,7 @@ "patchouli.gui.lexicon.edition_str.ord.7":"%1$sth", "patchouli.gui.lexicon.edition_str.ord.8":"%1$sth", "patchouli.gui.lexicon.edition_str.ord.9":"%1$sth", + "patchouli.gui.lexicon.edition_str.ord.uu":"%2$s", "patchouli.gui.lexicon.edition_str.ord.00":"%2$s", "patchouli.gui.lexicon.edition_str.ord.10":"%1$sth", "patchouli.gui.lexicon.edition_str.ord.20":"%2$s", From 3d7565ff2646757dcc6d1b7701a8480ad3f22a05 Mon Sep 17 00:00:00 2001 From: WVam <83856938+WVam@users.noreply.github.com> Date: Fri, 3 Mar 2023 12:06:07 +0100 Subject: [PATCH 09/11] Removed recursive reference --- .../main/java/vazkii/patchouli/common/book/Book.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java index 23298e39..1f869db0 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java @@ -298,9 +298,8 @@ private static Component numberToOrdinal(int i) { it will pick a suffix based on the units alone (the translation of .). - If the translation is "%3$s", then for all the numbers with those tens it will pick a translation based on both units AND tens. This translation can be: - - "%1$s" (default tens suffix) + - "%1$s" (a special suffix) - "%2$s" (default units suffix) - - "%3$s" (a special suffix) If the tens of a number are equal to 0, 'tens' can have three possible values: - "uu" if the number is less than 10 (1, 2, 3, ...) - "00" if the number is greater than 10 and number's hundreds are equal to 0 (1001, 2002, 3003, ...) @@ -308,10 +307,9 @@ it will pick a suffix based on the units alone (the translation of . Date: Fri, 3 Mar 2023 12:27:57 +0100 Subject: [PATCH 10/11] Fixed names --- Xplat/src/main/java/vazkii/patchouli/common/book/Book.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java index 1f869db0..30cb5c11 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java @@ -257,7 +257,7 @@ public Style getFontStyle() { } public MutableComponent getSubtitle() { - Component edition; + Component editionStr; try { int ver = Integer.parseInt(version); @@ -272,7 +272,7 @@ public MutableComponent getSubtitle() { return Component.translatable("patchouli.gui.lexicon.dev_edition"); } - return Component.translatable("patchouli.gui.lexicon.edition_str", edition); + return Component.translatable("patchouli.gui.lexicon.edition_str", editionStr); } public BookIcon getIcon() { From 22b75f55d9089ef12c20decfeb573b21e516aaa5 Mon Sep 17 00:00:00 2001 From: WVam <83856938+WVam@users.noreply.github.com> Date: Thu, 6 Apr 2023 12:35:35 +0200 Subject: [PATCH 11/11] Missing comma --- Xplat/src/main/java/vazkii/patchouli/common/book/Book.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java index 30cb5c11..8efa3397 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java @@ -305,7 +305,7 @@ it will pick a suffix based on the units alone (the translation of .