1: <?php
2: namespace Define\Utilities;
3: use Define\Traits\SingletonTrait;
4:
5: if(!defined('DIRECT_ACCESS')) {
6: die("Direct access is forbidden.");
7: }
8:
9: /**
10: * LOCALIZATION
11: *
12: * Singleton localization implementation.
13: *
14: * @category Define
15: * @package Utilities
16: * @author Nitesh Apte <me@niteshapte.com>
17: * @copyright 2015 Nitesh Apte
18: * @version 1.0.0
19: * @since 1.0.0
20: * @license https://www.gnu.org/licenses/gpl.txt GNU General Public License v3
21: *
22: * This program is free software: you can redistribute it and/or modify
23: * it under the terms of the GNU General Public License as published by
24: * the Free Software Foundation, either version 3 of the License, or
25: * (at your option) any later version.
26: *
27: * This program is distributed in the hope that it will be useful,
28: * but WITHOUT ANY WARRANTY; without even the implied warranty of
29: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30: * GNU General Public License for more details.
31: *
32: * You should have received a copy of the GNU General Public License
33: * along with this program. If not, see <http://www.gnu.org/licenses/>.
34: */
35: class Localization implements IUtilities {
36:
37: // Yes, keep it singleton
38: use SingletonTrait;
39:
40: /**
41: *
42: * @param string $language
43: * @return string
44: */
45: public function loadLanguage($language = "en") {
46: return file_exists(LOCALIZATION_PATH.$language.'/'.$language.'.php') ? LOCALIZATION_PATH.$language.'/'.$language.'.php' : LOCALIZATION_PATH.DEFAULT_LANGUAGE.'/'.DEFAULT_LANGUAGE.'.php';
47: }
48: }