forked from Motion-Project/motion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translate.c
64 lines (53 loc) · 1.49 KB
/
translate.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Translations for Web User control interface.
*
* This software is distributed under the GNU Public License Version 2
* See also the file 'COPYING'.
*
*/
#include <locale.h>
#include "motion.h"
#include "translate.h"
void translate_locale_chg(const char *langcd){
#ifdef HAVE_INTL
/* This routine is for development testing only. It is not used for
* regular users because once this locale is change, it changes the
* whole computer over to the new locale. Therefore, we just return
*/
return;
setenv ("LANGUAGE", langcd, 1);
/* Invoke external function to change locale*/
++_nl_msg_cat_cntr;
#else
if (langcd != NULL) MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO,"No native language support");
#endif
}
void translate_init(void){
#ifdef HAVE_INTL
/* Set the flag to enable native language support */
nls_enabled = 1;
setlocale (LC_ALL, "");
//translate_locale_chg("li");
translate_locale_chg("es");
bindtextdomain ("motion", LOCALEDIR);
bind_textdomain_codeset ("motion", "UTF-8");
textdomain ("motion");
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO,_("Language: English"));
#else
/* Disable native language support */
nls_enabled = 0;
/* This avoids a unused function warning */
translate_locale_chg("en");
#endif
}
char* translate_text(const char *msgid){
#ifdef HAVE_INTL
if (nls_enabled){
return (char*)gettext(msgid);
} else {
return (char*)msgid;
}
#else
return (char*)msgid;
#endif
}