Merge pull request #3002 from owncloud/priorize_common_languages

Priorize common languages.
This commit is contained in:
Bart Visscher 2013-04-26 06:30:59 -07:00
commit d825669265
3 changed files with 21 additions and 4 deletions

View file

@ -92,6 +92,9 @@ $(document).ready(function(){
});
$("#languageinput").chosen();
// Show only the not selectable optgroup
// Choosen only shows optgroup-labels if there are options in the optgroup
$(".languagedivider").remove();
$("#languageinput").change( function(){
// Serialize the data

View file

@ -22,8 +22,14 @@ $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
$userLang=OC_Preferences::getValue( 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_JP', 'nl', 'it', 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'zh_CN', 'ko'
);
$languageNames=include 'languageCodes.php';
$languages=array();
$commonlanguages = array();
foreach($languageCodes as $lang) {
$l=OC_L10N::get('settings', $lang);
if(substr($l->t('__language_name__'), 0, 1)!='_') {//first check if the language name is in the translation file
@ -34,8 +40,12 @@ foreach($languageCodes as $lang) {
$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[]=$ln;
} else {
$languages[]=$ln;
}
@ -46,9 +56,6 @@ usort( $languages, function ($a, $b) {
return strcmp($a['name'], $b['name']);
});
//put the current language in the front
array_unshift($languages, $userLang);
//links to clients
$clients = array(
'desktop' => OC_Config::getValue('customclient_desktop', 'http://owncloud.org/sync-clients/'),
@ -64,6 +71,8 @@ $tmpl->assign('usage_relative', $storageInfo['relative']);
$tmpl->assign('clients', $clients);
$tmpl->assign('email', $email);
$tmpl->assign('languages', $languages);
$tmpl->assign('commonlanguages', $commonlanguages);
$tmpl->assign('activelanguage', $userLang);
$tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
$tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser()));
$tmpl->assign('displayName', OC_User::getDisplayName());

View file

@ -76,11 +76,16 @@ if($_['displayNameChangeSupported']) {
<fieldset class="personalblock">
<legend><strong><?php p($l->t('Language'));?></strong></legend>
<select id="languageinput" class="chzen-select" name="lang" data-placeholder="<?php p($l->t('Language'));?>">
<option value="<?php p($_['activelanguage']['code']);?>"><?php p($_['activelanguage']['name']);?></option>
<?php foreach($_['commonlanguages'] as $language):?>
<option value="<?php p($language['code']);?>"><?php p($language['name']);?></option>
<?php endforeach;?>
<optgroup label=""><option class="languagedivider">-</option></optgroup>
<?php foreach($_['languages'] as $language):?>
<option value="<?php p($language['code']);?>"><?php p($language['name']);?></option>
<?php endforeach;?>
</select>
<a href="https://www.transifex.net/projects/p/owncloud/team/<?php p($_['languages'][0]['code']);?>/"
<a href="https://www.transifex.net/projects/p/owncloud/team/<?php p($_['activelanguage']['code']);?>/"
target="_blank"><em><?php p($l->t('Help translate'));?></em></a>
</fieldset>
</form>