"Fossies" - the Fresh Open Source Software Archive

Member "motion-Release-4.3.0/src/translate.c" (14 Jan 2020, 1536 Bytes) of package /linux/misc/motion-Release-4.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "translate.c" see the Fossies "Dox" file reference documentation.

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