1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-01 18:43:33 +02:00
VVVVVV/desktop_version/src/LocalizationStorage.h

93 lines
2.5 KiB
C
Raw Permalink Normal View History

#ifndef LOCALIZATIONSTORAGE_H
#define LOCALIZATIONSTORAGE_H
#include <tinyxml2.h>
#include "Textbook.h"
#include "XMLUtils.h"
extern "C"
{
#include <c-hashmap/map.h>
}
#if defined(LOCALIZATIONSTORAGE_CPP)
#define LS_INTERN
#else
#define LS_INTERN extern
#endif
namespace loc
{
#if defined(LOCALIZATION_CPP) || defined(LOCALIZATIONSTORAGE_CPP) || defined(LOCALIZATIONMAINT_CPP)
LS_INTERN Textbook textbook_main;
LS_INTERN Textbook textbook_custom;
LS_INTERN hashmap* map_translation;
LS_INTERN hashmap* map_translation_plural;
LS_INTERN std::string number[101]; /* 0..100 */
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
LS_INTERN std::string number2[101]; /* 0..100 */
LS_INTERN unsigned char number_plural_form[200]; /* [0..99] for 0..99, [100..199] for *00..*99 */
LS_INTERN hashmap* map_translation_cutscene;
LS_INTERN hashmap* map_translation_cutscene_custom;
LS_INTERN hashmap* map_translation_roomnames_special;
#define MAP_MAX_X 54
#define MAP_MAX_Y 56
#define CUSTOM_MAP_MAX_X 19
#define CUSTOM_MAP_MAX_Y 19
LS_INTERN const char* translation_roomnames[MAP_MAX_Y+1][MAP_MAX_X+1];
LS_INTERN const char* explanation_roomnames[MAP_MAX_Y+1][MAP_MAX_X+1];
LS_INTERN const char* translation_roomnames_custom[CUSTOM_MAP_MAX_Y+1][CUSTOM_MAP_MAX_X+1];
LS_INTERN const char* explanation_roomnames_custom[CUSTOM_MAP_MAX_Y+1][CUSTOM_MAP_MAX_X+1];
#endif
struct TextOverflow
{
std::string lang;
const char* text;
unsigned short max_w, max_h;
unsigned short max_w_px, max_h_px;
bool multiline;
uint32_t flags;
};
extern std::vector<TextOverflow> text_overflows;
bool load_lang_doc(
const std::string& cat,
tinyxml2::XMLDocument& doc,
const std::string& langcode = lang,
const std::string& asset_cat = ""
);
unsigned char form_for_count(int n);
void unloadtext_custom(void);
void resettext(bool final_shutdown);
bool parse_max(const char* max, unsigned short* max_w, unsigned short* max_h);
const char* get_level_original_lang(tinyxml2::XMLHandle& hDoc);
bool store_roomname_translation(bool custom_level, int roomx, int roomy, const char* tra, const char* explanation);
bool fix_room_coords(bool custom_level, int* roomx, int* roomy);
void loadtext(bool check_max);
void loadtext_custom(const char* custom_path);
void loadlanguagelist(void);
const char* map_lookup_text(hashmap* map, const char* eng, const char* fallback);
char* add_disambiguator(char disambiguator, const char* original_string, size_t* ext_alloc_len);
} /* namespace loc */
#undef LS_INTERN
#endif /* LOCALIZATIONSTORAGE_H */