2022-12-29 05:22:40 +01:00
|
|
|
#ifndef LOCALIZATION_H
|
|
|
|
#define LOCALIZATION_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
/* The translator menu will appear in any of the following circumstances:
|
|
|
|
* - The "lang" folder is NOT next to data.zip, but it is found in "desktop_version" within which the game is running
|
|
|
|
* - The command line argument "-translator" is passed
|
|
|
|
* - ALWAYS_SHOW_TRANSLATOR_MENU is defined
|
|
|
|
*/
|
|
|
|
// #define ALWAYS_SHOW_TRANSLATOR_MENU
|
|
|
|
|
|
|
|
namespace loc
|
|
|
|
{
|
|
|
|
|
|
|
|
struct LangMeta
|
|
|
|
{
|
|
|
|
bool active; // = true, language is shown in the list
|
|
|
|
std::string code;
|
|
|
|
std::string nativename;
|
|
|
|
std::string credit;
|
|
|
|
std::string action_hint;
|
2023-03-26 20:15:45 +02:00
|
|
|
std::string gamepad_hint;
|
2022-12-29 05:22:40 +01:00
|
|
|
bool autowordwrap; // = true; enable automatic wordwrapping
|
|
|
|
bool toupper; // = true; enable automatic full-caps for menu options
|
|
|
|
bool toupper_i_dot; // = false; enable Turkish i mapping when uppercasing
|
|
|
|
bool toupper_lower_escape_char; // = false; enable ~ to mark lowercase letters for uppercasing
|
2024-01-03 19:07:28 +01:00
|
|
|
bool rtl; // = false; enable for RTL languages like Arabic or Hebrew
|
2022-12-29 05:22:40 +01:00
|
|
|
std::string menu_select;
|
|
|
|
std::string menu_select_tight;
|
2023-01-15 01:31:02 +01:00
|
|
|
uint8_t font_idx;
|
2022-12-29 05:22:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TextboxFormat
|
|
|
|
{
|
|
|
|
const char* text;
|
|
|
|
unsigned short wraplimit; // = 36*8-pad_left-pad_right; no effect if tt or !langmeta.autowordwrap
|
|
|
|
unsigned short wraplimit_raw; // original value of wraplimit, only used for language file sync
|
|
|
|
bool tt; // teletype, don't auto-wordwrap
|
|
|
|
bool centertext; // whether the text should be centered inside the box
|
|
|
|
unsigned char pad_left; // pad with X characters
|
|
|
|
unsigned char pad_right;
|
|
|
|
unsigned short padtowidth; // pad to X pixels (0 to disable)
|
|
|
|
};
|
|
|
|
|
2024-02-08 03:35:05 +01:00
|
|
|
extern int lang_set;
|
|
|
|
static const int lang_set_current = 2;
|
Fix "no language files found" title screen bug
If you've never set a language before (<lang_set> is not 1), then the
language screen will show up before the title screen. Selecting the
language will then make the title screen show up.
If no language files are present, the old logic for handling this was
to simply show the language screen at startup anyway, and let it
display the error message that language files are missing, as a warning
that the game is not packaged correctly. However, this logic has two
flaws:
- If the user has ever had language files and set a language before
(in a VVVVVV on that computer), the warning element is gone because
the language screen is not shown in that case - the game is simply in
English
- If the user has never set a language before, and then goes to the
language screen later via the menu, they will be sent to the title
screen, even if they were in-game. The main menu will also be broken.
The new way is to not show the language screen at startup if language
files are missing, and to change the logic so that you will only be
sent to the title screen if you actually haven't seen the title screen
yet.
I will also add a proper warning that fonts or language files are
missing by adding a message in the bottom left corner (in place of the
MMMMMM installed message).
2023-08-29 23:03:08 +02:00
|
|
|
extern bool pre_title_lang_menu;
|
|
|
|
|
2022-12-29 05:22:40 +01:00
|
|
|
extern std::string lang;
|
|
|
|
extern std::string lang_custom;
|
2023-10-02 02:44:13 +02:00
|
|
|
extern bool english_sprites;
|
2023-01-21 19:06:30 +01:00
|
|
|
extern std::string new_level_font;
|
2022-12-29 05:22:40 +01:00
|
|
|
extern LangMeta langmeta;
|
|
|
|
extern std::vector<LangMeta> languagelist;
|
|
|
|
extern int languagelist_curlang;
|
|
|
|
extern bool show_translator_menu;
|
|
|
|
extern size_t limitscheck_current_overflow;
|
2022-12-24 04:16:56 +01:00
|
|
|
extern std::vector<std::string> testable_script_ids;
|
2022-12-29 05:22:40 +01:00
|
|
|
|
|
|
|
extern int n_untranslated_roomnames;
|
|
|
|
extern int n_unexplained_roomnames;
|
|
|
|
extern int n_untranslated_roomnames_custom;
|
|
|
|
extern int n_unexplained_roomnames_custom;
|
2022-11-27 20:06:08 +01:00
|
|
|
extern int n_untranslated_roomnames_area[9];
|
2022-12-29 05:22:40 +01:00
|
|
|
|
|
|
|
enum n_untranslated_index
|
|
|
|
{
|
|
|
|
UNTRANSLATED_STRINGS = 0,
|
|
|
|
UNTRANSLATED_NUMBERS,
|
|
|
|
UNTRANSLATED_STRINGS_PLURAL,
|
|
|
|
UNTRANSLATED_CUTSCENES,
|
|
|
|
UNTRANSLATED_ROOMNAMES_SPECIAL,
|
|
|
|
COUNT_UNTRANSLATED_INDEX
|
|
|
|
};
|
|
|
|
extern int n_untranslated[COUNT_UNTRANSLATED_INDEX];
|
|
|
|
|
|
|
|
|
|
|
|
const LangMeta* get_langmeta(void);
|
|
|
|
|
|
|
|
const char* gettext(const char* eng);
|
Add support for string cases in strings.xml (gendered Rescued/Missing)
I wanted to not complicate the system with different string cases (like
cgettext) if possible, and I have been able to keep the main strings a
simple English=Translation mapping thus far, but apparently strings
like "Rescued!" (which are one string in English), have to be
translated for the correct gender in some languages. So this was a good
time to add support for string cases anyway.
It's a number that can be given to a string to specify the specific
case it's used, to disambiguate identical English keys. In the case of
"Rescued!" and "Missing...", male versions of the string are case 1,
female versions are case 2, and Viridian being missing is case 3. Of
course, if a language doesn't need to use different variants, it can
simply fill in the same string for the different cases.
If any other string needs to switch to different cases: distinguish
them in the English strings.xml with the case="N" attribute (N=1 and
higher), sync language files from the translator menu (existing
translations for the uncased string will simply be copied to all cases)
and change loc::gettext("...") to loc::gettext_case("...", 1),
loc::gettext_case("...", 2), etc.
2022-12-01 01:27:30 +01:00
|
|
|
const char* gettext_case(const char* eng, char textcase);
|
2022-12-29 05:22:40 +01:00
|
|
|
const char* gettext_plural(const char* eng_plural, const char* eng_singular, int count);
|
|
|
|
void gettext_plural_fill(char* buf, size_t buf_len, const char* eng_plural, const char* eng_singular, const char* args_index, ...);
|
Add a system for selecting between wordy/wordy2
Some languages have different spellings of wordy numbers based on the
gender of the things they're counting (uno crewmate versus una trinket)
or what a number's role is in the sentence (e.g. twenta out of twentu).
We've always had the idea we couldn't support such complex differences
though, because the game can't be adapted to know what gender each
object will have and what word classes might exist in other languages,
so translators would in those cases just have to forgo the wordy
numbers and just let the game use "20 out of 20".
A solution we came up semi-recently though (after all translations were
finished except for Arabic), was to allow the translator to define
however many classes of wordy numbers they need, and fill them all out.
This would not need the game to be *adapted* for every language's
specific grammar and word genders/classes. Instead, the translator
would just choose their correct self-defined class at the time they use
`wordy` in the VFormat placeholder. Something like
{n|wordy|class=feminine}, or {n|wordy_feminine}.
So this would benefit several languages, but we came up with the
solution a little late for all languages to benefit from it. The Arabic
translators asked for two separate classes of wordy numbers though, so
my plan is to first just have a second list of wordy numbers
(translation2 in numbers.xml), which can be accessed by passing the
`wordy2` flag to VFormat, instead of `wordy`.
Once 2.4 is released, we can take our time to do it properly. This
would involve the ability for translators to define however many
classes they need, to name them what they want, and this name would
then be useable in VFormat placeholders. We can convert all existing
translations to have one class defined by default, such as "wordy", or
"translation" depending on implementation, but there's not so much
concern for maintaining backwards compatibility here, so we can do a
mass-switchover for all language files. That said, it wouldn't be too
hard to add a special case for "translation" being "wordy" either.
We can then ask translators if they would like to change anything with
the new system in place.
For now, we can use this system for Arabic, maybe Spanish since there
were complaints about uno/una, and *maybe* Dutch (it has a thing where
the number "one" is often capitalized differently, but it's not
mandatory per se)
2024-01-06 04:15:06 +01:00
|
|
|
std::string getnumber(int n, const char* number_class);
|
2022-12-29 05:22:40 +01:00
|
|
|
const TextboxFormat* gettext_cutscene(const std::string& script_id, const std::string& eng, char textcase);
|
|
|
|
const char* get_roomname_explanation(bool custom_level, int roomx, int roomy);
|
|
|
|
const char* get_roomname_translation(bool custom_level, int roomx, int roomy);
|
|
|
|
const char* gettext_roomname(bool custom_level, int roomx, int roomy, const char* eng, bool special);
|
|
|
|
const char* gettext_roomname_special(const char* eng);
|
|
|
|
|
|
|
|
bool is_cutscene_translated(const std::string& script_id);
|
|
|
|
|
|
|
|
uint32_t toupper_ch(uint32_t ch);
|
|
|
|
std::string toupper(const std::string& lower);
|
|
|
|
std::string remove_toupper_escape_chars(const std::string& _s);
|
|
|
|
|
|
|
|
} /* namespace loc */
|
|
|
|
|
|
|
|
#endif /* LOCALIZATION_H */
|