Exemplo n.º 1
0
 /**
  * Test all locale files for the supplied locale against the supplied
  * reference locale, returning an array of errors.
  * @param $locale string Name of locale to test
  * @param $referenceLocale string Name of locale to test against
  * @return array
  */
 function testLocale($locale, $referenceLocale)
 {
     $localeFileNames = AppLocale::getFilenameComponentMap($locale);
     $errors = array();
     foreach ($localeFileNames as $localeFileName) {
         $referenceLocaleFileName = str_replace($locale, $referenceLocale, $localeFileName);
         $localeFile = new LocaleFile($locale, $localeFileName);
         $referenceLocaleFile = new LocaleFile($referenceLocale, $referenceLocaleFileName);
         $errors = array_merge_recursive($errors, $localeFile->testLocale($referenceLocaleFile));
         unset($localeFile);
         unset($referenceLocaleFile);
     }
     $plugins =& PluginRegistry::loadAllPlugins();
     foreach (array_keys($plugins) as $key) {
         $plugin =& $plugins[$key];
         $referenceLocaleFilenames = $plugin->getLocaleFilename($referenceLocale);
         if ($referenceLocaleFilenames) {
             if (is_scalar($referenceLocaleFilenames)) {
                 $referenceLocaleFilenames = array($referenceLocaleFilenames);
             }
             $localeFilenames = $plugin->getLocaleFilename($locale);
             if (is_scalar($localeFilenames)) {
                 $localeFilenames = array($localeFilenames);
             }
             assert(count($localeFilenames) == count($referenceLocaleFilenames));
             foreach ($referenceLocaleFilenames as $index => $referenceLocaleFilename) {
                 assert(isset($localeFilenames[$index]));
                 $localeFile = new LocaleFile($locale, $localeFilenames[$index]);
                 $referenceLocaleFile = new LocaleFile($referenceLocale, $referenceLocaleFilename);
                 $errors = array_merge_recursive($errors, $localeFile->testLocale($referenceLocaleFile));
                 unset($localeFile);
                 unset($referenceLocaleFile);
             }
         }
         unset($plugin);
     }
     return $errors;
 }
Exemplo n.º 2
0
 /**
  * Test all locale files for the supplied locale against the supplied
  * reference locale, returning an array of errors.
  * @param $locale string Name of locale to test
  * @param $referenceLocale string Name of locale to test against
  * @return array
  */
 function testLocale($locale, $referenceLocale)
 {
     $localeFileNames = Locale::getFilenameComponentMap($locale);
     $errors = array();
     foreach ($localeFileNames as $localeFileName) {
         $referenceLocaleFileName = str_replace($locale, $referenceLocale, $localeFileName);
         $localeFile = new LocaleFile($locale, $localeFileName);
         $referenceLocaleFile = new LocaleFile($referenceLocale, $referenceLocaleFileName);
         $errors = array_merge_recursive($errors, $localeFile->testLocale($referenceLocaleFile));
         unset($localeFile);
         unset($referenceLocaleFile);
     }
     $plugins =& PluginRegistry::loadAllPlugins();
     foreach (array_keys($plugins) as $key) {
         $plugin =& $plugins[$key];
         $referenceLocaleFilename = $plugin->getLocaleFilename($referenceLocale);
         if ($referenceLocaleFilename) {
             $localeFile = new LocaleFile($locale, $plugin->getLocaleFilename($locale));
             $referenceLocaleFile = new LocaleFile($referenceLocale, $referenceLocaleFilename);
             $errors = array_merge_recursive($errors, $localeFile->testLocale($referenceLocaleFile));
             unset($localeFile);
             unset($referenceLocaleFile);
         }
         unset($plugin);
     }
     return $errors;
 }