1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xmf;
13:
14: /**
15: * Language
16: *
17: * TODO fix
18: *
19: * @category Xmf\Module\Language
20: * @package Xmf
21: * @author trabis <lusopoemas@gmail.com>
22: * @copyright 2011-2013 XOOPS Project (http://xoops.org)
23: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
24: * @version Release: 1.0
25: * @link http://xoops.org
26: * @since 1.0
27: */
28: class Language
29: {
30: /**
31: * Attempt a translation of a simple string
32: *
33: * @param string $string string to translate
34: * @param string $domain language domain
35: *
36: * @return string translated string
37: *
38: * @todo do something useful
39: */
40: public static function translate($string, $domain = null)
41: {
42: return $string;
43: }
44:
45: /**
46: * load - load a language file
47: *
48: * @param string $name name of the language file
49: * @param string $domain domain or module supplying language file
50: * @param string $language language folder name
51: *
52: * @return bool true if loaded, otherwise false
53: */
54: public static function load($name, $domain = '', $language = null)
55: {
56: if (empty($language)) {
57: if (!empty($GLOBALS['xoopsConfig']['language'])) {
58: $language = $GLOBALS['xoopsConfig']['language'];
59: } else {
60: $language = 'english';
61: }
62: }
63: $path = \XoopsBaseConfig::get('root-path') . '/' . ((empty($domain) || 'global' === $domain) ? ''
64: : "modules/{$domain}/") . 'language';
65: if (!$ret = Loader::loadFile("{$path}/{$language}/{$name}.php")) {
66: $ret = Loader::loadFile("{$path}/english/{$name}.php");
67: }
68:
69: return $ret;
70: }
71: }
72: