Ejemplo n.º 1
0
 /**
  * Gets all the available languages
  *
  * @param   string  $defaultLang    Current used language
  *
  * @return array    An array of the form:
  *     ['languages'       => <languages>,
  *      'commonlanguages' => <common_languages>,
  *      'activelanguage'  => <active_language>]
  *     where:
  *     - languages is an array with all the ownCloud languages (except the
  *       common ones) of the form:
  *          [['code' => <lang_code>, 'name' => <translated_lang_name], ...]
  *     - commonlanguages is an array with the common ownCloud languages
  *     - active_language is the current used language
  *
  * @remarks: This code was taken from:
  *       * <ownCloudRoot>/settings/personal.php
  *       Unfortunatelly there isn't an utility for this at the
  *       moment of writting
  */
 public function getAvailableLanguages($defaultLang)
 {
     $userLang = $defaultLang;
     //It would be nice this method to be a public method (not static) of
     //L10N
     $languageCodes = \OC_L10N::findAvailableLanguages();
     // array of common languages
     $commonlangcodes = array('en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it', 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko');
     //This is also an ugly hack, but it was taken from the OwnCloud core lib
     $languageNames = (include \OC::$SERVERROOT . '/settings/languageCodes.php');
     $languages = array();
     $commonlanguages = array();
     $server = $this->app->getContainer()->getServer();
     foreach ($languageCodes as $lang) {
         $l = $server->getL10N('settings', $lang);
         if (substr($l->t('__language_name__'), 0, 1) !== '_') {
             //first check if the language name is in the translation file
             $ln = array('code' => $lang, 'name' => (string) $l->t('__language_name__'));
         } elseif (isset($languageNames[$lang])) {
             $ln = array('code' => $lang, 'name' => $languageNames[$lang]);
         } else {
             //fallback to language code
             $ln = array('code' => $lang, 'name' => $lang);
         }
         // put apropriate languages into apropriate arrays, to print them
         // sorted used language -> common languages -> divider -> other
         //languages
         if ($lang === $userLang) {
             $userLang = $ln;
         } elseif (in_array($lang, $commonlangcodes)) {
             $commonlanguages[array_search($lang, $commonlangcodes)] = $ln;
         } else {
             $languages[] = $ln;
         }
     }
     ksort($commonlanguages);
     // sort now by displayed language not the iso-code
     usort($languages, function ($a, $b) {
         return strcmp($a['name'], $b['name']);
     });
     return array('languages' => $languages, 'commonlanguages' => $commonlanguages, 'activelanguage' => $userLang);
 }
Ejemplo n.º 2
0
OC_Util::addStyle('settings', 'settings');
\OC_Util::addVendorScript('strengthify/jquery.strengthify');
\OC_Util::addVendorStyle('strengthify/strengthify');
\OC_Util::addScript('files', 'jquery.iframe-transport');
\OC_Util::addScript('files', 'jquery.fileupload');
if ($config->getSystemValue('enable_avatars', true) === true) {
    \OC_Util::addVendorScript('jcrop/js/jquery.Jcrop');
    \OC_Util::addVendorStyle('jcrop/css/jquery.Jcrop');
}
// Highlight navigation entry
OC::$server->getNavigationManager()->setActiveEntry('personal');
$storageInfo = OC_Helper::getStorageInfo('/');
$user = OC::$server->getUserManager()->get(OC_User::getUser());
$email = $user->getEMailAddress();
$userLang = $config->getUserValue(OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage());
$languageCodes = OC_L10N::findAvailableLanguages();
// array of common languages
$commonLangCodes = array('en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it', 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko');
$languageNames = (include 'languageCodes.php');
$languages = array();
$commonLanguages = array();
foreach ($languageCodes as $lang) {
    $l = \OC::$server->getL10N('settings', $lang);
    // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version
    if (substr($l->t('__language_name__'), 0, 1) !== '_') {
        //first check if the language name is in the translation file
        $ln = array('code' => $lang, 'name' => (string) $l->t('__language_name__'));
    } elseif (isset($languageNames[$lang])) {
        $ln = array('code' => $lang, 'name' => $languageNames[$lang]);
    } else {
        //fallback to language code
Ejemplo n.º 3
0
* 
*/
// Check if we are a user
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('conversations');
OCP\App::setActiveNavigationEntry('conversations');
// register js and css
OCP\Util::addscript('conversations', 'conversations');
OCP\Util::addScript('conversations', 'jquery.infinitescroll.min');
OCP\Util::addScript('conversations', 'jquery.autosize.min');
OCP\Util::addScript('conversations', 'jquery.timeago');
OCP\Util::addstyle('conversations', 'style');
// add timeago translations
$lang = OC_L10N::findLanguage('conversations');
// TODO: may find a better solution than file_exists
if (in_array($lang, OC_L10N::findAvailableLanguages('conversations')) && file_exists('./apps/conversations/js/jquery.timeago.' . $lang . '.js')) {
    OCP\Util::addScript('conversations', 'jquery.timeago.' . $lang);
}
// rooms
$rooms = OC_Conversations::getRooms();
$updates = OC_Conversations::updateCheck();
$rooms = array_merge_recursive($rooms, $updates);
// get the page that is requested. Needed for endless scrolling
$count = 5;
if (isset($_GET['page'])) {
    $page = intval($_GET['page']) - 1;
} else {
    $page = 0;
}
$nextpage = \OCP\Util::linkToAbsolute('conversations', 'index.php', array('page' => $page + 2));
$tmpl = new OCP\Template('conversations', 'main', 'user');