From b1e857cf1471d1871a9396696b22fa531da98249 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 23 Nov 2024 22:33:43 +0100 Subject: add projbase to repo --- project-base/src/localization.h | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 project-base/src/localization.h (limited to 'project-base/src/localization.h') diff --git a/project-base/src/localization.h b/project-base/src/localization.h new file mode 100644 index 0000000..983a193 --- /dev/null +++ b/project-base/src/localization.h @@ -0,0 +1,61 @@ +/* +* BSD 2-Clause “Simplified” License +* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com +* All rights reserved. +*/ + +#ifndef INCLUDE_LOCALIZATION +#define INCLUDE_LOCALIZATION + +// https://www.science.co.il/language/Locale-codes.php + +typedef struct t_mo_entry +{ + s32 length; + s32 offset; +} mo_entry; + +typedef struct t_mo_translation +{ + s32 identifier_len; + char *identifier; + char *translation; +} mo_translation; + +typedef struct t_mo_header +{ + s32 magic_number; + s32 file_format_revision; + s32 number_of_strings; + s32 identifier_table_offset; + s32 translation_table_offset; + s32 hashtable_size; + s32 hashtable_offset; +} mo_header; + +typedef struct t_mo_file +{ + mo_header header; + array translations; + char *locale_id; + char *locale_full; + image *icon; +} mo_file; + +typedef struct t_localization +{ + array mo_files; + mo_file *active_localization; + bool loaded; +} localization; + +localization global_localization = {0}; + +char* locale_get_id(); +char* locale_get_name(); +char* localize(const char *identifier); +bool localization_set_locale(char *country_id); +void localization_init(); +void localization_destroy(); + +#endif \ No newline at end of file -- cgit v1.2.3-70-g09d2