38#ifdef WITH_INTERNATIONAL
46static const char **locales =
nullptr;
47static int num_locales = 0;
49static int num_locales_menu = 0;
51static void free_locales()
54 int idx = num_locales_menu - 1;
65 num_locales = num_locales_menu = 0;
68static void fill_locales()
71 if (!languages_path.has_value()) {
72 CLOG_WARN(&
LOG,
"'locale' data path for translations not found");
97 if (t >= num_locales) {
110 if (num_locales > 0) {
113 const char *loc, *desc, *sep1, *sep2, *sep3;
115 char *
str = (
char *)line->
link;
121 const int id = atoi(
str);
122 sep1 = strchr(
str,
':');
125 sep2 = strchr(sep1,
':');
127 locales_menu[idx].
value = id;
128 locales_menu[idx].
icon = 0;
132 sep3 = strchr(sep2,
':');
138 desc =
BLI_sprintfN(
"Locale code: %s. Translation progress: %s", loc, sep3);
147 if (loc[0] !=
'\0') {
153 "Automatically choose the system-defined language if available, or fall-back to "
176 locales_menu[idx].
value = locales_menu[idx].
icon = 0;
185#ifdef WITH_INTERNATIONAL
208 if (lang !=
nullptr) {
209 char *old_locale = setlocale(LC_ALL,
nullptr);
212 if (setlocale(LC_ALL, lang) ==
nullptr) {
213 setenv(
"LANG",
"C", 1);
214 CLOG_WARN(&
LOG,
"Falling back to standard locale (\"C\")");
216 setlocale(LC_ALL, old_locale);
221#ifdef WITH_INTERNATIONAL
228#ifdef WITH_INTERNATIONAL
234#ifdef WITH_INTERNATIONAL
235static uint lang_from_userdef()
245#ifdef WITH_INTERNATIONAL
246# define ULANGUAGE lang_from_userdef()
247# define LOCALE(_id) (locales ? locales[(_id)] : "")
252#ifdef WITH_INTERNATIONAL
253 int ulang = ULANGUAGE;
254 std::string locale_name =
str ?
str : LOCALE(ulang);
267#ifdef WITH_INTERNATIONAL
269 const char *locale = LOCALE(ULANGUAGE);
270 if (locale[0] ==
'\0') {
289 char **language_country,
290 char **language_variant)
295 m1 = strchr(locale,
'_');
296 m2 = strchr(locale,
'@');
298 if (language || language_variant) {
325 if (language_country) {
330 *language_country =
nullptr;
333 if (language_variant) {
338 *language_variant =
nullptr;
341 if (_t && !language) {
std::optional< std::string > BKE_appdir_folder_id(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
File and directory operations.
struct LinkNode * BLI_file_read_as_lines(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_file_free_lines(struct LinkNode *lines)
#define BLI_path_join(...)
const char * BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
char * BLI_strdupcat(const char *__restrict str1, const char *__restrict str2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define CLOG_WARN(clg_ref,...)
Read Guarded memory(de)allocation.
void BLT_lang_locale_explode(const char *locale, char **language, char **country, char **variant, char **language_country, char **language_variant)
const char * BLT_lang_get()
const EnumPropertyItem * BLT_lang_RNA_enum_properties()
void BLT_lang_set(const char *str)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
void init(const StringRef locale_full_name, const Vector< std::string > &domains, const Vector< std::string > &paths)