Commit Graph
14 Commits
Author SHA1 Message Date
Gleb Mazovetskiy 56f94c7471 Add a --lang command line argument
This allows forcing the locale without changing the settings.

The `forceLocale` option also lets us avoid changing the locale in settings if fonts.mpq is missing, fixing the following scenario:
1. System locale is ja
2. Launch the game -- fonts are missing
3. Close the game, download fonts.mpq
4. Launch the game again -- it is now in English because the settings have changed
2022-12-10 02:26:11 +00:00
Gleb Mazovetskiy 254806e027 Optimize translation RAM usage
1. Store all key data and all values data as 2 char arrays.
2. Change map keys to char pointers.
3. Change map values to offsets into the values array.

Example savings for Russian: 460 KiB -> 374.2 KiB (-85.8 KiB)

* Map: 68.5 KiB (with `string_view` keys it would be 101.5 KiB)
* Keys array: 108.7 KiB
* Values array: 197.0 KiB
2022-07-08 11:52:18 +01:00
Gleb Mazovetskiy 779ccaca17 Overhaul translation fetching
1. Do not modify the map after loading. Instead, return string views
   (guaranteed to be null-terminated) from look up functions and return
   the key directly if not found.
2. Use an `unorded_map` instead of `map` where available (C++20).
   Saves a bit of RAM (~50 KiB) and improves lookup performance.
2022-06-14 12:46:36 +01:00
Anders Jenbo 1409e604f5 Reduce string conversions 2022-03-20 11:04:15 +01:00
Gleb Mazovetskiy 4f64b87330 Fix talk/store text overlap for Chinese and Japanese
We ensure that selectable lines are placed at the same vertical
coordinates but space out unselectable text lines at the cost
of reduced heigh of empty space between the store items.

We also have to move the back button in scrollable lists to the
lower right.

This can definitely be improved further but at least it solves
the problem for now.

Refs #3162
2021-11-20 02:31:21 +00:00
Anders Jenbo 671fdbd125 Implement contextural translation (pgettext)
Fixes #2369
Fixes #2790
2021-09-20 04:18:35 +02:00
Anders Jenbo 5c2a559487 Get default langauge 2021-08-01 12:35:24 +02:00
Anders Jenbo 18f3a0c5ea ✨ Support for plural forms in translations
The implementation isn't robust, dynamic or pretty, but works for now.
2021-05-01 19:27:55 +02:00
Gleb Mazovetskiy 979bedb8c2 🐞 Fix memory leaks in utils/language.{h,cpp}
This is a minimal refactoring to fix the memory leaks which have made
reading debug output impossible.
2021-04-30 14:16:13 +02:00
Gleb Mazovetskiy c025bf6050 🎨 Fix line endings in utils/language.{h,cpp} 2021-04-30 14:16:13 +02:00
John Törnblom 9c61baea9f parse translation metadata 2021-04-25 12:42:00 +02:00
Anders Jenbo 32117dc73b 🔧 Create translation template and update translations 2021-04-25 04:56:15 +02:00
John Törnblom 04269dedcd add translation macro for msgids defined in the global scope 2021-04-25 03:40:51 +02:00
John Törnblom 51e7a169a6 add initial language support using a simple MO parser 2021-04-25 03:40:45 +02:00