From: "Matteo F. Vescovi" Date: Thu, 5 Aug 2021 22:53:36 +0200 Subject: locales_directory_install Change where locales are installed. Contributions by: Antonio Ospite Gleb Fotengauer-Malinovskiy --- source/blender/blenkernel/BKE_appdir.h | 1 + source/blender/blenkernel/intern/appdir.c | 3 +++ source/blender/blentranslation/intern/blt_lang.c | 10 +++++----- source/creator/CMakeLists.txt | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/BKE_appdir.h b/source/blender/blenkernel/BKE_appdir.h index 6548505..69e4b5c 100644 --- a/source/blender/blenkernel/BKE_appdir.h +++ b/source/blender/blenkernel/BKE_appdir.h @@ -94,6 +94,7 @@ enum { BLENDER_SYSTEM_DATAFILES = 52, BLENDER_SYSTEM_SCRIPTS = 53, BLENDER_SYSTEM_PYTHON = 54, + BLENDER_SYSTEM_LOCALE = 55, }; /* for BKE_appdir_folder_id_version only */ diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index 08a3b7d..a9b7d38 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -721,6 +721,9 @@ bool BKE_appdir_folder_id_ex(const int folder_id, } return false; + case BLENDER_SYSTEM_LOCALE: + BLI_strncpy(path, "/usr/share/locale", FILE_MAX); break; + default: BLI_assert_unreachable(); break; diff --git a/source/blender/blentranslation/intern/blt_lang.c b/source/blender/blentranslation/intern/blt_lang.c index 91e8a81..6574810 100644 --- a/source/blender/blentranslation/intern/blt_lang.c +++ b/source/blender/blentranslation/intern/blt_lang.c @@ -78,9 +78,9 @@ static void free_locales(void) num_locales = num_locales_menu = 0; } -static void fill_locales(void) +static void fill_locales(char *locale_path) { - const char *const languages_path = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale"); + const char * const languages_path = locale_path; char languages[FILE_MAX]; LinkNode *lines = NULL, *line; char *str; @@ -88,7 +88,7 @@ static void fill_locales(void) free_locales(); - BLI_join_dirfile(languages, FILE_MAX, languages_path, "languages"); + BLI_join_dirfile(languages, FILE_MAX, locale_path, "languages"); line = lines = BLI_file_read_as_lines(languages); /* This whole "parsing" code is a bit weak, in that it expects strictly formatted input file... @@ -195,7 +195,7 @@ EnumPropertyItem *BLT_lang_RNA_enum_properties(void) void BLT_lang_init(void) { #ifdef WITH_INTERNATIONAL - const char *const messagepath = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale"); + const char * const messagepath = BKE_appdir_folder_id(BLENDER_SYSTEM_LOCALE, NULL); #endif /* Make sure LANG is correct and wouldn't cause #std::runtime_error. */ @@ -228,7 +228,7 @@ void BLT_lang_init(void) #ifdef WITH_INTERNATIONAL if (messagepath) { bl_locale_init(messagepath, TEXT_DOMAIN_NAME); - fill_locales(); + fill_locales(messagepath); } else { printf("%s: 'locale' data path for translations not found, continuing\n", __func__); diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 83779a8..9836c8f 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -407,7 +407,7 @@ install( # localization if(WITH_INTERNATIONAL) set(_locale_dir "${CMAKE_SOURCE_DIR}/release/datafiles/locale") - set(_locale_target_dir ${TARGETDIR_VER}/datafiles/locale) + set(_locale_target_dir ${CMAKE_INSTALL_PREFIX}/share/locale) file(GLOB _po_files "${_locale_dir}/po/*.po") foreach(_po_file ${_po_files})