File: SpotTranslation.php

package info (click to toggle)
spotweb 20130826%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,132 kB
  • ctags: 11,281
  • sloc: php: 31,367; xml: 1,009; sh: 148; makefile: 83
file content (49 lines) | stat: -rwxr-xr-x 1,314 bytes parent folder | download | duplicates (2)
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
<?php
/*
 * Translation code for Spotweb
 */
class SpotTranslation {

	public static function initialize($lang) {
		# Do we have native gettext?
		if (extension_loaded('gettext')) {
			putenv("LC_ALL=" . $lang . ".UTF-8");
			setlocale(LC_ALL, $lang . '.UTF-8');

			# Initialize the textdomain
			bindtextdomain('messages', 'locales/');
			bind_textdomain_codeset('messages', 'UTF-8');
			textdomain('messages');
		} else {
			global $_gt_obj;
			$_gt_obj = new Gettext_PHP('locales', 'messages', $lang);
		} # else
	} # initialize
} # class SpotTranslation


/*
 * This is procedural code because we want these functions to
 * be in the global name space
 */
if (!extension_loaded('gettext')) {
	function _($msg) {
		return $GLOBALS['_gt_obj']->gettext($msg);
	} # _ alias of gettext

	function gettext($msg) {
		return $GLOBALS['_gt_obj']->gettext($msg);
	} # gettext

	function dgettext($domain, $msg) {
		return $GLOBALS['_gt_obj']->dgettext($domain, $msg);
	} # dgettext

	function ngettext($msg, $msg_plural, $count) {
		return $GLOBALS['_gt_obj']->ngettext($msg, $msg_plural, $count);
	} # ngettext

	function dngettext($domain, $msg, $msg_plural, $count) {
		return $GLOBALS['_gt_obj']->dngettext($domain, $msg, $msg_plural, $count);
	} # dngettext
} # if