/** * Install a new locale. * @param $args array * @param $request object */ function installLocale($args, &$request) { $this->validate(); $site =& $request->getSite(); $installLocale = $request->getUserVar('installLocale'); if (isset($installLocale) && is_array($installLocale)) { $installedLocales = $site->getInstalledLocales(); foreach ($installLocale as $locale) { if (AppLocale::isLocaleValid($locale) && !in_array($locale, $installedLocales)) { array_push($installedLocales, $locale); AppLocale::installLocale($locale); } } $site->setInstalledLocales($installedLocales); $siteDao =& DAORegistry::getDAO('SiteDAO'); $siteDao->updateObject($site); } $request->redirect(null, null, 'languages'); }
/** * Reload locale-specific data. * @param $locale string */ function reloadLocale($locale) { AppLocale::uninstallLocale($locale); AppLocale::installLocale($locale); }
/** * @copydoc Form::execute() */ function execute($request) { $site = $request->getSite(); $localesToInstall = $this->getData('localesToInstall'); if (isset($localesToInstall) && is_array($localesToInstall)) { $installedLocales = $site->getInstalledLocales(); $supportedLocales = $site->getSupportedLocales(); foreach ($localesToInstall as $locale) { if (AppLocale::isLocaleValid($locale) && !in_array($locale, $installedLocales)) { array_push($installedLocales, $locale); // Activate/support by default. if (!in_array($locale, $supportedLocales)) { array_push($supportedLocales, $locale); } AppLocale::installLocale($locale); } } $site->setInstalledLocales($installedLocales); $site->setSupportedLocales($supportedLocales); $siteDao = DAORegistry::getDAO('SiteDAO'); $siteDao->updateObject($site); } }