bvschaik / julius

An open source re-implementation of Caesar III
GNU Affero General Public License v3.0
2.79k stars 311 forks source link

Add Catalan localisation #697

Closed J0anJosep closed 6 months ago

J0anJosep commented 1 year ago

I would like to make Catalan language available in Julius and Augustus. This PR modifies the corresponding files and adds the Catalan translated strings for Julius.

I have tested it and the only problem I have found so far is that the middle dot is rendered as an empty space. So, instead of "cancel·la" it is shown as "cancel la": imatge

If this could be amended, please, could you tell me what should I do so it can be solved in this same PR?

Thank you very much!

crudelios commented 1 year ago

I think this could be fixed by using the dot image but a bit elevated so it would provide the desired result, however I don't know enough about the text encoding and font rendering processes to do that.

Hopefully @bvschaik has a better idea on how to do it.

bvschaik commented 1 year ago

Crudelios' suggestion might work, I'll look into that.

The more important question: did you also translate the game itself into Catalan? (the two .eng files) If so, please attach them to this PR, so we can test the code.

bvschaik commented 1 year ago

I looked into displaying the middle dot, you can do that with the following patch:

diff --git a/src/graphics/font.c b/src/graphics/font.c
index a5261232..caa57688 100644
--- a/src/graphics/font.c
+++ b/src/graphics/font.c
@@ -29,7 +29,7 @@ static const int CHAR_TO_FONT_IMAGE_DEFAULT[] = {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00,
     0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+    0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
     0x72, 0x70, 0x71, 0x71, 0x69, 0x83, 0x6D, 0x65, 0x74, 0x6A, 0x73, 0x73, 0x77, 0x75, 0x76, 0x76,
     0x00, 0x6C, 0x7A, 0x78, 0x79, 0x79, 0x7B, 0x00, 0x84, 0x7E, 0x7C, 0x7D, 0x6B, 0x33, 0x00, 0x68,
     0x53, 0x52, 0x54, 0x51, 0x51, 0x85, 0x67, 0x65, 0x57, 0x56, 0x58, 0x55, 0x5B, 0x5A, 0x5C, 0x59,
@@ -237,6 +237,10 @@ static int image_y_offset_default(uint8_t c, int image_height, int line_height)
     if (c < 0x80 || c == 0xE7) {
         offset = 0;
     }
+    if (c == 0xB7) {
+        // middle dot: uses the image for '.', so needs to be shifted upwards
+        offset = line_height / 3;
+    }
     return offset;
 }
J0anJosep commented 1 year ago

I looked into displaying the middle dot, you can do that with the following patch:

diff --git a/src/graphics/font.c b/src/graphics/font.c
index a5261232..caa57688 100644
--- a/src/graphics/font.c
+++ b/src/graphics/font.c
@@ -29,7 +29,7 @@ static const int CHAR_TO_FONT_IMAGE_DEFAULT[] = {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00,
     0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+    0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
     0x72, 0x70, 0x71, 0x71, 0x69, 0x83, 0x6D, 0x65, 0x74, 0x6A, 0x73, 0x73, 0x77, 0x75, 0x76, 0x76,
     0x00, 0x6C, 0x7A, 0x78, 0x79, 0x79, 0x7B, 0x00, 0x84, 0x7E, 0x7C, 0x7D, 0x6B, 0x33, 0x00, 0x68,
     0x53, 0x52, 0x54, 0x51, 0x51, 0x85, 0x67, 0x65, 0x57, 0x56, 0x58, 0x55, 0x5B, 0x5A, 0x5C, 0x59,
@@ -237,6 +237,10 @@ static int image_y_offset_default(uint8_t c, int image_height, int line_height)
     if (c < 0x80 || c == 0xE7) {
         offset = 0;
     }
+    if (c == 0xB7) {
+        // middle dot: uses the image for '.', so needs to be shifted upwards
+        offset = line_height / 3;
+    }
     return offset;
 }

Yes. It works perfectly. Thanks!

bvschaik commented 6 months ago

Closing due to inactivity. If you have an update, just comment here and we can reopen.