public function build() { $this->setLayout('manager/findi18n.tpl'); $findI18N = new ManagerFindi18nController(); $locales_available = $findI18N->getFilesystemFiles("instances/{$this->instance}/locale"); foreach ($locales_available as $key => $locale) { if (false === strpos($locale, 'messages_')) { unset($locales_available[$key]); // Rebuild only "messages". } } $literals = $findI18N->getLiterals($this->instance); // Look for master file and save contents from literals: foreach ($locales_available as $key => $locale) { if (strpos($locale, self::MASTER_LANGUAGE) !== false) { $master_strings = $this->getTranslationStrings($locale, $literals); unset($locales_available[$key]); $this->saveStrings($locale, $master_strings); } } $master_keys = array_keys($master_strings); foreach ($locales_available as $key => $locale) { $translated_strings = $this->getTranslationStrings($locale, $literals); // Remove keys not present in master: foreach ($translated_strings as $key_translated => $value_translated) { if (!in_array($key_translated, $master_keys)) { unset($translated_strings[$key_translated]); } } $this->saveStrings($locale, $translated_strings); } die("Locales rebuilt"); }
public function build() { header('Content-Type: text/plain'); $this->setLayout('manager/findi18n.tpl'); try { $master_routes = \Sifo\Config::getInstance($this->instance)->getConfig('lang/router_' . self::MASTER_LANGUAGE); } catch (Exception_Configuration $e) { die('The master file does not exist. ' . $e->getMessage()); } $findI18N = new ManagerFindi18nController(); $files_available = $findI18N->getFilesystemFiles("instances/{$this->instance}/config/lang"); foreach ($files_available as $key => $filename) { // Is a 'router' config file (but not master) if (strpos($filename, 'router_') !== false) { $translated_routes = $this->getTranslatedRoutes($filename); // Remove keys not present in master: foreach ($translated_routes as $route => $route_translated) { if (!isset($master_routes[$route])) { unset($translated_routes[$route]); echo "Deleted route {$route} in {$filename}\n"; } } // Add keys not present in master foreach ($master_routes as $route => $route_translated) { if (!isset($translated_routes[$route])) { $translated_routes[$route] = $route_translated; } } ksort($translated_routes); $this->saveConfig($filename, $translated_routes); } } echo "\n\nRoutes rebuild!"; die; }