Server IP : 103.119.228.120 / Your IP : 18.221.8.126 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/awl/inc/ |
Upload File : |
<?php /** * Functions involved in translating with gettext * @package awl * @subpackage Translation * @author Andrew McMillan <andrew@mcmillan.net.nz> * @copyright Catalyst IT Ltd * @license http://gnu.org/copyleft/gpl.html GNU GPL v2 or later */ if ( !function_exists('i18n') ) { /** * Mark a string as being internationalized. This is a semaphore method; it * does nothing but it allows us to easily identify strings that require * translation. Generally this is used to mark strings that will be stored * in the database (like descriptions of permissions). * * AWL uses GNU gettext for internationalization (i18n) and localization (l10n) of * text presented to the user. Gettext needs to know about all places involving strings, * that must be translated. Mark any place, where localization at runtime shall take place * by using the function translate(). * * In the help I have used 'xlate' rather than 'translate' and 'x18n' rather than 'i18n' * so that the tools skip this particular file for translation :-) * * E.g. instead of: * print 'TEST to be displayed in different languages'; * use: * print xlate('TEST to be displayed in different languages'); * and you are all set for pure literals. The translation teams will receive that literal * string as a job to translate and will translate it (when the message is clear enough). * At runtime the message is then localized when printed. * The input string can contain a hint to assist translators: * print xlate('TT <!-- abbreviation for Translation Test -->'); * The hint portion of the string will not be printed. * * But consider this case: * $message_to_be_localized = 'TEST to be displayed in different languages'; * print xlate($message_to_be_localized); * * The translate() function is called in the right place for runtime handling, but there * is no message at gettext preprocessing time to be given to the translation teams, * just a variable name. Translation of the variable name would break the code! So all * places potentially feeding this variable have to be marked to be given to translation * teams, but not translated at runtime! * * This method resolves all such cases. Simply mark the candidates: * $message_to_be_localized = x18n('TEST to be displayed in different languages'); * print xlate($message_to_be_localized); * * @param string the value * @return string the same value */ function i18n($value) { return $value; /* Just pass the value through */ } } if ( !function_exists('translate') ) { /** * Convert a string in English to whatever this user's locale is */ if ( function_exists('gettext') ) { function translate( $en ) { if ( ! isset($en) || $en == '' ) return $en; $xl = gettext($en); dbg_error_log('I18N','Translated =%s= into =%s=', $en, $xl ); return $xl; } } else { function translate( $en ) { return $en; } } } if ( !function_exists('init_gettext') ) { /** * Initialise our use of Gettext */ function init_gettext( $domain, $location ) { if ( !function_exists('bindtextdomain') ) return; $location = bindtextdomain( $domain, $location ); $codeset = bind_textdomain_codeset( $domain, 'UTF-8' ); $domain = textdomain( $domain ); dbg_error_log('I18N','Bound domain =%s= to location =%s= using character set =%s=', $domain, $location, $codeset ); } } if ( !function_exists('awl_set_locale') ) { /** * Set the translation to the user's locale. At this stage all we do is * call the gettext function. */ function awl_set_locale( $locale ) { global $c; if ( !is_array($locale) && ! preg_match('/^[a-z]{2}(_[A-Z]{2})?\./', $locale ) ) { $locale = array( $locale, $locale.'.UTF-8'); } if ( !function_exists('setlocale') ) { dbg_log_array('WARN','No "setlocale()" function? PHP gettext support missing?' ); return; } if ( $newlocale = setlocale( LC_ALL, $locale) ) { dbg_error_log('I18N','Set locale to =%s=', $newlocale ); $c->current_locale = $newlocale; } else { dbg_log_array('I18N','Unsupported locale: ', $locale, false ); } } }