1: <?php
2: /**
3: *
4: * @package XCube
5: * @version $Id: XCube_LanguageManager.class.php,v 1.4 2008/10/12 04:30:27 minahito Exp $
6: * @copyright Copyright 2005-2007 XOOPS Cube Project <https://github.com/xoopscube/legacy>
7: * @license https://github.com/xoopscube/legacy/blob/master/docs/bsd_licenses.txt Modified BSD license
8: *
9: */
10:
11: /**
12: * This class manages resources of each languages. By requests of other
13: * components, this class loads files, or checks the existence of the specified
14: * resource, or composes filepath to access real files. And, it manages some
15: * locale informations.
16: *
17: * Rules about language are different at each bases. So it's important that a
18: * base defines the sub class of this class if it can't use this class directly.
19: *
20: * And, XCube or bases have to make each languages possible to have its sub
21: * class. By that, languages become able to implement their logic to solve
22: * problems.
23: *
24: * This class calls sub directories of each languages 'section'. 'section' is
25: * used to load image files and etc.
26: */
27: class XCube_LanguageManager
28: {
29: /**
30: * @access protected
31: * @var string
32: */
33: var $mLanguageName;
34:
35: /**
36: * @access protected
37: * @var string
38: */
39: var $mLocaleName;
40:
41: function XCube_LanguageManager()
42: {
43: $this->mLanguageName = $this->getFallbackLanguage();
44: $this->mLocaleName = $this->getFallbackLocale();
45: }
46:
47: /**
48: * Normally, this member function is called soon, after constructor.
49: * To follow the base, initialize.
50: */
51: function prepare()
52: {
53: }
54:
55: /**
56: * Set locale name.
57: *
58: * @param string $local locale name
59: */
60: function setLocale($locale)
61: {
62: $this->mLanguageName = $locale;
63: }
64:
65: /**
66: * Get locale name.
67: *
68: * @return string locale name
69: */
70: function getLocale()
71: {
72: return $this->mLanguageName;
73: }
74:
75: /**
76: * Set language name.
77: *
78: * @param string $language language name
79: */
80: function setLanguage($language)
81: {
82: $this->mLanguageName = $language;
83: }
84:
85: /**
86: * Get language name.
87: *
88: * @return string language name
89: */
90: function getLanguage()
91: {
92: return $this->mLanguageName;
93: }
94:
95: /**
96: * Load the global message catalog which is defined in the base module.
97: */
98: function loadGlobalMessageCatalog()
99: {
100: }
101:
102: /**
103: * Load the module message catalog which is defined in the specified
104: * module.
105: *
106: * @param string $moduleName A name of module.
107: */
108: function loadModuleMessageCatalog($moduleName)
109: {
110: }
111:
112: /**
113: * Load the theme message catalog which is defined in the specified module.
114: *
115: * @param string $themeName A name of theme.
116: */
117: function loadThemeMessageCatalog($themeName)
118: {
119: }
120:
121: /**
122: * check the exstence of the specified file in the specified section.
123: *
124: * @access public
125: * @param string $section A name of section.
126: * @param string $filename A name of file
127: * @return bool
128: */
129: function existFile($section, $filename)
130: {
131: }
132:
133: /**
134: * Return the file path by the specified section and the specified file.
135: *
136: * @access public
137: * @param string $section A name of section.
138: * @param string $filename A name of file
139: * @return string
140: */
141: function getFilepath($section, $filename)
142: {
143: }
144:
145: /**
146: * Get file contents and return it.
147: *
148: * @access public
149: * @param string $section A name of section.
150: * @param string $filename A name of file
151: * @return string
152: */
153: function loadTextFile($section, $filename)
154: {
155: }
156:
157: /**
158: * Return translated message.
159: *
160: * @param string $word
161: * @return string
162: *
163: * @note This member function is test.
164: */
165: function translate($word)
166: {
167: return $word;
168: }
169:
170: /**
171: * Return default language name.
172: *
173: * @access protected
174: * @return string
175: */
176: function getFallbackLanguage()
177: {
178: return "eng";
179: }
180:
181: /**
182: * Return default locale name.
183: *
184: * @access protected
185: * @return string
186: */
187: function getFallbackLocale()
188: {
189: return "EG";
190: }
191:
192: function encodeUTF8($str)
193: {
194: return $str;
195: }
196:
197: function decodeUTF8($str)
198: {
199: return $str;
200: }
201: }
202:
203: ?>