/**
  * @depends testGetAvailableLanguages
  */
 public function testGetPoFileUrl()
 {
     $url = ZurmoTranslationServerUtil::getPoFileUrl('de');
     $headers = get_headers($url);
     list($version, $status_code, $msg) = explode(' ', $headers[0], 3);
     $this->assertEquals(200, intval($status_code));
 }
 public function actionConfigurationList()
 {
     $breadCrumbLinks = array(Zurmo::t('Core', 'Languages'));
     $messageBoxContent = Zurmo::t('ZurmoModule', 'Don\'t see a language that you want to load? ' . 'Help us make Zurmo better by contributing on a translation. ' . 'Click <a href="{l10nServerDomain}" class="simple-link normal-size" target="_blank">here</a>.', array('{l10nServerDomain}' => ZurmoTranslationServerUtil::getServerDomain()));
     $view = new LanguageTitleBarConfigurationListView($this->getId(), $this->getModule()->getId(), $messageBoxContent);
     $view = new ZurmoConfigurationPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $view, $breadCrumbLinks, 'SettingsBreadCrumbView'));
     echo $view->render();
 }
Beispiel #3
0
 public function actionConfigurationList()
 {
     $redirectUrlParams = array('/zurmo/' . $this->getId() . '/ConfigurationList');
     $messageBoxContent = Zurmo::t('ZurmoModule', 'Don\'t see a language that you want to load? Help us make Zurmo better by contributing on a translation. Click <a href="{l10nServerDomain}" class="simple-link normal-size" target="_blank">here</a>.', array('{l10nServerDomain}' => ZurmoTranslationServerUtil::getServerDomain()));
     $view = new LanguageTitleBarConfigurationListView($this->getId(), $this->getModule()->getId(), $messageBoxContent);
     $view = new ZurmoConfigurationPageView(ZurmoDefaultAdminViewUtil::makeStandardViewForCurrentUser($this, $view));
     echo $view->render();
 }
 /**
  * Retrives the list of all languages available on the l10n server
  */
 public static function getAvailableLanguages()
 {
     if (is_array(self::$availableLanguages) && !empty(self::$availableLanguages)) {
         return self::$availableLanguages;
     }
     try {
         $l10nInfo = self::getServerInfo();
     } catch (FailedServiceException $e) {
         throw new FailedServiceException();
     }
     self::$availableLanguages = array();
     foreach ($l10nInfo->languages->language as $language) {
         self::$availableLanguages[$language->code] = array('code' => $language->code, 'name' => $language->name, 'nativeName' => $language->native);
     }
     if (is_array(self::$availableLanguages) && !empty(self::$availableLanguages)) {
         return self::$availableLanguages;
     }
     throw new FailedServiceException();
 }
 /**
  * Updates a language
  */
 public function updateLanguage($languageCode)
 {
     try {
         $language = ActiveLanguage::getByCode($languageCode);
     } catch (NotFoundException $e) {
         throw new NotFoundException(Zurmo::t('ZurmoModule', 'Language not active.'));
     }
     $translationUrl = ZurmoTranslationServerUtil::getPoFileUrl($language->code);
     // Check if the po file exists
     $headers = get_headers($translationUrl);
     list($version, $status_code, $msg) = explode(' ', $headers[0], 3);
     if ($status_code != 200) {
         throw new NotFoundException(Zurmo::t('ZurmoModule', 'Translation not available.'));
     }
     if (ZurmoMessageSourceUtil::importPoFile($language->code, $translationUrl)) {
         $language->lastUpdateDatetime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
         if ($language->save()) {
             return true;
         }
     }
     throw new FailedServiceException(Zurmo::t('ZurmoModule', 'Unexpected error. Please try again later.'));
 }