4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2008 Blender Foundation.
21 * All rights reserved.
23 * Contributor(s): Blender Foundation.
25 * ***** END GPL LICENSE BLOCK *****
38 #include "DNA_listBase.h"
39 #include "DNA_vec_types.h"
43 #include "BLI_blenlib.h"
44 #include "BLI_linklist.h" /* linknode */
45 #include "BLI_string.h"
52 #define DOMAIN_NAME "blender"
53 #define SYSTEM_ENCODING_DEFAULT "UTF-8"
54 #define FONT_SIZE_DEFAULT 12
57 char global_messagepath[1024];
58 char global_language[32];
59 char global_encoding_name[32];
62 void BLF_lang_init(void)
64 char *messagepath= BLI_get_folder(BLENDER_DATAFILES, "locale");
66 BLI_strncpy(global_encoding_name, SYSTEM_ENCODING_DEFAULT, sizeof(global_encoding_name));
69 BLI_strncpy(global_messagepath, messagepath, sizeof(global_messagepath));
71 global_messagepath[0]= '\0';
75 void BLF_lang_set(const char *str)
77 #if defined (_WIN32) || defined(__APPLE__)
78 BLI_setenv("LANG", str);
80 char *locreturn= setlocale(LC_ALL, str);
81 if (locreturn == NULL) {
84 lang= (char*)malloc(sizeof(char)*(strlen(str)+7));
88 strcat(lang, ".UTF-8");
90 locreturn= setlocale(LC_ALL, lang);
91 if (locreturn == NULL) {
92 printf("could not change language to %s nor %s\n", str, lang);
98 setlocale(LC_NUMERIC, "C");
100 textdomain(DOMAIN_NAME);
101 bindtextdomain(DOMAIN_NAME, global_messagepath);
102 /* bind_textdomain_codeset(DOMAIN_NAME, global_encoding_name); */
103 strcpy(global_language, str);
106 void BLF_lang_encoding(const char *str)
108 strcpy(global_encoding_name, str);
109 /* bind_textdomain_codeset(DOMAIN_NAME, encoding_name); */
112 #else /* ! INTERNATIONAL */
114 void BLF_lang_init(void)
119 void BLF_lang_encoding(char *str)
125 void BLF_lang_set(char *str)
131 #endif /* INTERNATIONAL */