function register($category, $path) { if (parent::register($category, $path)) { if ($this->getEnabled()) { // Add custom locale data for already registered locale files. $locale = AppLocale::getLocale(); $localeFiles = AppLocale::getLocaleFiles($locale); $journal = Request::getJournal(); $journalId = $journal->getId(); $publicFilesDir = Config::getVar('files', 'public_files_dir'); $customLocalePathBase = $publicFilesDir . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR; import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); foreach ($localeFiles as $localeFile) { $customLocalePath = $customLocalePathBase . $localeFile->getFilename(); if ($fileManager->fileExists($customLocalePath)) { AppLocale::registerLocaleFile($locale, $customLocalePath, true); } } // Add custom locale data for all locale files registered after this plugin HookRegistry::register('PKPLocale::registerLocaleFile', array(&$this, 'addCustomLocale')); } return true; } return false; }
/** * Register a locale file against the current list. * @param $locale string Locale key * @param $filename string Filename to new locale XML file * @param $addToTop boolean Whether to add to the top of the list (true) * or the bottom (false). Allows overriding. */ function ®isterLocaleFile($locale, $filename, $addToTop = false) { $localeFiles =& AppLocale::getLocaleFiles($locale); $localeFile = new LocaleFile($locale, $filename); if (!$localeFile->isValid()) { $localeFile = null; return $localeFile; } if ($addToTop) { // Work-around: unshift by reference. array_unshift($localeFiles, ''); $localeFiles[0] =& $localeFile; } else { $localeFiles[] =& $localeFile; } HookRegistry::call('PKPLocale::registerLocaleFile', array(&$locale, &$filename, &$addToTop)); return $localeFile; }