1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00
VVVVVV/desktop_version/src/LocalizationStorage.h
Dav999-v 17d3c756c7 Write max_local to language files during sync
If your language has a bigger font, the max attribute isn't really
helpful to you as a translator, so the sync feature adds a special
max_local attribute which is accurate to the font size. This was
already documented in advance.

If used, we now also write an attribute in the root tag of strings.xml
and strings_plural.xml, that looks like max_local_for="12x12". I
decided to add this attribute after finding out the Excel macros would
be really hard to change to only show a max_local column if it is ever
used (it'd need to look ahead through the strings until it finds a
string with a max, or remove the column if no string has used it), but
it's also a convenience for translators.
2023-02-13 23:27:00 -08:00

91 lines
2.5 KiB
C++

#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 */
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 */