diff --git a/core/text/i18n/i18n.odin b/core/text/i18n/i18n.odin index e007401af..9d030db16 100644 --- a/core/text/i18n/i18n.odin +++ b/core/text/i18n/i18n.odin @@ -163,16 +163,20 @@ get_by_slot :: proc{get_by_slot_single_section, get_by_slot_by_section} - destroy(), to clean up the currently active catalog catalog i18n.ACTIVE - destroy(catalog), to clean up a specific catalog. */ -destroy :: proc(catalog: ^Translation = ACTIVE) { - if catalog != nil { - strings.intern_destroy(&catalog.intern) - for section in &catalog.k_v { - for key in &catalog.k_v[section] { - delete(catalog.k_v[section][key]) - } - delete(catalog.k_v[section]) - } - delete(catalog.k_v) - free(catalog) +destroy :: proc(catalog: ^Translation = ACTIVE, allocator := context.allocator) { + context.allocator = allocator + + if catalog == nil { + return } + + for section in &catalog.k_v { + for key in &catalog.k_v[section] { + delete(catalog.k_v[section][key]) + } + delete(catalog.k_v[section]) + } + delete(catalog.k_v) + strings.intern_destroy(&catalog.intern) + free(catalog) } \ No newline at end of file diff --git a/core/text/i18n/qt_linguist.odin b/core/text/i18n/qt_linguist.odin index 0a241c1aa..e23e9aef4 100644 --- a/core/text/i18n/qt_linguist.odin +++ b/core/text/i18n/qt_linguist.odin @@ -59,7 +59,10 @@ parse_qt_linguist_from_slice :: proc(data: []u8, options := DEFAULT_PARSE_OPTION return translation, .TS_File_Expected_Context_Name, } - section_name := "" if options.merge_sections else ts.elements[section_name_id].value + section_name := strings.intern_get(&translation.intern, "") + if !options.merge_sections { + section_name = strings.intern_get(&translation.intern, ts.elements[section_name_id].value) + } if section_name not_in translation.k_v { translation.k_v[section_name] = {} diff --git a/tests/core/Makefile b/tests/core/Makefile index 1405ae5c6..5c2918e30 100644 --- a/tests/core/Makefile +++ b/tests/core/Makefile @@ -2,7 +2,7 @@ ODIN=../../odin PYTHON=$(shell which python3) all: download_test_assets image_test compress_test strings_test hash_test crypto_test noise_test encoding_test \ - math_test linalg_glsl_math_test filepath_test reflect_test os_exit_test + math_test linalg_glsl_math_test filepath_test reflect_test os_exit_test i18n_test download_test_assets: $(PYTHON) download_assets.py @@ -44,4 +44,7 @@ reflect_test: $(ODIN) run reflect/test_core_reflect.odin -file -collection:tests=.. -out:test_core_reflect os_exit_test: - $(ODIN) run os/test_core_os_exit.odin -file -out:test_core_os_exit && exit 1 || exit 0 \ No newline at end of file + $(ODIN) run os/test_core_os_exit.odin -file -out:test_core_os_exit && exit 1 || exit 0 + +i18n_test: + $(ODIN) run text/i18n -out:test_core_i18n \ No newline at end of file diff --git a/tests/core/assets/I18N/duplicate-key.ts b/tests/core/assets/I18N/duplicate-key.ts index a38824d01..44c09d91d 100644 --- a/tests/core/assets/I18N/duplicate-key.ts +++ b/tests/core/assets/I18N/duplicate-key.ts @@ -10,13 +10,13 @@ - apple_count - - %d apple(s) - - %d appel - %d appels - - - + apple_count + + %d apple(s) + + %d appel + %d appels + + +