/** * This test aims at testing the tao_install_utils_System class methods. */ public function testSystemUtils() { // - Check if tao platform locales can be correctly retrieved. $locales = tao_install_utils_System::getAvailableLocales(dirname(__FILE__) . self::SAMPLE_LOCALES); $this->assertTrue(is_array($locales), 'Locales should be returned as an array of strings.'); $this->assertTrue(array_key_exists('EN', $locales), "Locale 'EN' should be found."); $this->assertTrue($locales['EN'] == 'English', "Wrong label for locale 'EN'."); $this->assertTrue(array_key_exists('DE', $locales), "Locale 'DE' should be found."); $this->assertTrue($locales['DE'] == 'German', "Wrong label for locale 'DE'."); $this->assertTrue(array_key_exists('FR', $locales), "Locale 'FR' should be found."); $this->assertTrue($locales['FR'] == 'French', "Wrong label for locale 'FR'."); $this->assertTrue(array_key_exists('LU', $locales), "Locale 'LU' should be found."); $this->assertTrue($locales['LU'] == 'Luxembourgish', "Wrong label for locale 'LU'."); $this->assertTrue(array_key_exists('SE', $locales), "Locale 'SE' should be found."); $this->assertTrue($locales['SE'] == 'Swedish', "Wrong label for locale 'SE'."); $this->assertTrue(array_key_exists('en-YO', $locales), "Locale 'en-YO' should be found."); $this->assertTrue($locales['en-YO'] == 'Yoda English', "Wrong label for locale 'en-YO'."); }
/** * Get the list of available languages in terms of locales in the /tao meta-extension folder. * * @param string $localesPath The path to the /locales directory to scan into. * @param boolean $sort Sort by alphetical order. * @return array an array of languages where keys are language tags and values are language labels in english (EN). */ private static function getAvailableLanguages($localesPath, $sort = true) { $languages = array(); try { $languages = tao_install_utils_System::getAvailableLocales($localesPath); if (true == $sort) { asort($languages); } } catch (Exception $e) { // Do nothing and return gracefully. } return $languages; }