Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
41.67% |
5 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| tao_helpers_translation_Utils | |
41.67% |
5 / 12 |
|
0.00% |
0 / 2 |
16.73 | |
0.00% |
0 / 1 |
| getDefaultLanguage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getAvailableLanguages | |
55.56% |
5 / 9 |
|
0.00% |
0 / 1 |
9.16 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
| 19 | * (under the project TAO-TRANSFER); |
| 20 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | /** |
| 26 | * Aims at providing common utility methods for the tao::helpers::translation |
| 27 | * |
| 28 | * @access public |
| 29 | * @author Jerome Bogaerts |
| 30 | * @package tao |
| 31 | * @since 2.2 |
| 32 | |
| 33 | * @version 1.0 |
| 34 | */ |
| 35 | class tao_helpers_translation_Utils |
| 36 | { |
| 37 | /** |
| 38 | * Returns the default language of TAO. |
| 39 | * |
| 40 | * @access public |
| 41 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 42 | * @return string |
| 43 | */ |
| 44 | public static function getDefaultLanguage() |
| 45 | { |
| 46 | $returnValue = (string) ''; |
| 47 | |
| 48 | |
| 49 | $returnValue = 'en-US'; |
| 50 | |
| 51 | |
| 52 | return (string) $returnValue; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Get the availables locales for the current installation (from installed extensions). |
| 57 | * @return string[] the list of all locales supported by the app (even though a locale is used in only one |
| 58 | * extension). |
| 59 | */ |
| 60 | public static function getAvailableLanguages() |
| 61 | { |
| 62 | $languages = []; |
| 63 | foreach (common_ext_ExtensionsManager::singleton()->getInstalledExtensions() as $extension) { |
| 64 | $localesDir = $extension->getDir() . 'locales/'; |
| 65 | foreach (glob($localesDir . '*') as $file) { |
| 66 | if (is_dir($file) && file_exists($file . '/messages.po')) { |
| 67 | $lang = basename($file); |
| 68 | if (!in_array($lang, $languages)) { |
| 69 | $languages[] = $lang; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | return $languages; |
| 75 | } |
| 76 | } |