Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(701)

Delta Between Two Patch Sets: source/blender/blenfont/intern/blf_lang.c

Issue 7102054: Blender i18n enhancements (Closed) Base URL: https://svn.blender.org/svnroot/bf-blender/trunk/blender/
Left Patch Set: Created 12 years, 2 months ago
Right Patch Set: Updated, removed the "context in text string" feature Created 12 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * ***** BEGIN GPL LICENSE BLOCK ***** 2 * ***** BEGIN GPL LICENSE BLOCK *****
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License 5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2 6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.· 7 * of the License, or (at your option) any later version.·
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 short_locale_utf8 = short_locale; 227 short_locale_utf8 = short_locale;
228 } 228 }
229 229
230 bl_locale_set(short_locale_utf8); 230 bl_locale_set(short_locale_utf8);
231 231
232 if (short_locale[0]) { 232 if (short_locale[0]) {
233 MEM_freeN((void *)short_locale_utf8); 233 MEM_freeN((void *)short_locale_utf8);
234 } 234 }
235 } 235 }
236 236
237 /* Get the current locale (short code, e.g. es_ES). */
237 const char *BLF_lang_get(void) 238 const char *BLF_lang_get(void)
238 { 239 {
239 » const char *uilang = LOCALE(ULANGUAGE); 240 » const char *locale = LOCALE(ULANGUAGE);
240 » if (uilang[0] == '\0') { 241 » if (locale[0] == '\0') {
241 /* Default locale, we have to find which one we are actually usi ng! */ 242 /* Default locale, we have to find which one we are actually usi ng! */
242 » » uilang = bl_locale_get(); 243 » » locale = bl_locale_get();
243 » } 244 » }
244 » return uilang; 245 » return locale;
245 } 246 }
246 247
247 #undef LOCALE 248 #undef LOCALE
248 #undef ULANGUAGE 249 #undef ULANGUAGE
249 250
250 #else /* ! WITH_INTERNATIONAL */ 251 #else /* ! WITH_INTERNATIONAL */
251 252
252 EnumPropertyItem *BLF_RNA_lang_enum_properties(void) 253 EnumPropertyItem *BLF_RNA_lang_enum_properties(void)
253 { 254 {
254 return NULL; 255 return NULL;
(...skipping 13 matching lines...) Expand all
268 { 269 {
269 return; 270 return;
270 } 271 }
271 272
272 const char *BLF_lang_get(void) 273 const char *BLF_lang_get(void)
273 { 274 {
274 return ""; 275 return "";
275 } 276 }
276 277
277 #endif /* WITH_INTERNATIONAL */ 278 #endif /* WITH_INTERNATIONAL */
279
280
281 /* Get locale's elements (if relevant pointer is not NULL and element actually e xists, e.g. if there is no variant,
282 * *variant and *language_variant will always be NULL).
283 * Non-null elements are always MEM_mallocN'ed, it's the caller's responsibility to free them.
284 * NOTE: Keep that one always available, you never know, may become useful even in no-WITH_INTERNATIONAL context...
285 */
286 void BLF_locale_explode(const char *locale, char **language, char **country, cha r **variant,
287 char **language_country, char **language_variant)
288 {
289 char *m1, *m2, *_t = NULL;
290
291 m1 = strchr(locale, '_');
292 m2 = strchr(locale, '@');
293
294 if (language || language_variant) {
295 if (m1 || m2) {
296 _t = m1 ? BLI_strdupn(locale, m1 - locale) : BLI_strdupn (locale, m2 - locale);
297 if (language)
298 *language = _t;
299 }
300 else if (language) {
301 *language = NULL;
302 }
303 }
304 if (country) {
305 if (m1)
306 *country = m2 ? BLI_strdupn(m1 + 1, m2 - (m1 + 1)) : BLI _strdup(m1 + 1);
307 else
308 *country = NULL;
309 }
310 if (variant) {
311 if (m2)
312 *variant = BLI_strdup(m2 + 1);
313 else
314 *variant = NULL;
315 }
316 if (language_country) {
317 if (m2)
318 *language_country = BLI_strdupn(locale, m2 - locale);
319 else
320 *language_country = NULL;
321 }
322 if (language_variant) {
323 if (m2)
324 *language_variant = m1 ? BLI_strdupcat(_t, m2 + 1) : BLI _strdup(locale);
325 else
326 *language_variant = NULL;
327 }
328 if (_t && !language) {
329 MEM_freeN(_t);
330 }
331 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b