php - Changing language flag and text on click -


back again new question.

i'm still working on projects website, , i'm kind of stuck simple option.

im trying show language flag @ menu current language. flag, no text (maybe we'll want later though).

right now, menu works this:

user_box.php

    <?php trace(__file__,'begin'); ?> <div id="userbox">   <ul id="account_more_menu">      <?php if(isset($_userbox_projects) && is_array($_userbox_projects) && count($_userbox_projects)) { ?>     <li><a href="<?php echo get_url('dashboard', 'my_projects') ?>"><?php echo lang('my projects') ?></a>       <ul> <?php if (logged_user()->canmanageprojects()) { ?>         <li><a href="<?php echo get_url('project', 'add') ?>"><?php echo lang('add project') ?></a></li>         <li><a href="<?php echo get_url('project', 'copy') ?>"><?php echo lang('copy project') ?></a></li> <?php } // if ?>         <li><span><?php echo lang('projects') ?>:</span></li>     <?php if(100 > count($_userbox_projects)) { ?>         <?php foreach($_userbox_projects $_userbox_project) { ?>         <li><a href="<?php echo $_userbox_project->getoverviewurl() ?>"><?php echo clean($_userbox_project->getname()) ?></a></li>         <?php } // foreach ?> <?php } else { ?>         <?php foreach($_userbox_projects $_userbox_project) { ?> <?php $name = clean($_userbox_project->getname()) ?> <?php $url = clean($_userbox_project->getoverviewurl()) ?> <?php $first = strtoupper(substr($name,0,1)); ?> <?php if (!array_key_exists($index, $first)) $index[$first]=array(); ?> <?php $index[$first][] = array($name, $url); ?>         <?php } // foreach ?>         <?php foreach($index $first => $items) { ?> <li><a href=#><?php echo $first ?></a><ul>           <?php foreach($items $item) { ?>         <li><a href="<?php echo $item[1] ?>"><?php echo $item[0] ?></a></li>           <?php } // foreach ?> </ul></li>         <?php } // foreach ?> <?php } // if ?> <?php   // plugin hook   plugin_manager()->do_action('my_projects_dropdown');   // plugin hook ?>       </ul>     </li>     <?php } // if ?>  <?php if (!is_null(active_project())) { ?> <?php if (use_permitted(logged_user(), active_project(), 'tasks')) { ?> <?php if (isset($_userbox_projects) && is_array($_userbox_projects) && count($_userbox_projects)) { ?>     <li><a href="<?php echo get_url('dashboard', 'my_tasks') ?>"><?php echo lang('my tasks') ?></a>       <ul>         <li><span><?php echo clean(active_project()->getname()) ?>:</span></li>         <li><a href="<?php echo get_url('project', 'overview') ?>"><?php echo lang('overview') ?></a></li>         <li class="header"><a href="<?php echo get_url('message', 'index') ?>"><?php echo lang('messages') ?></a></li> <?php if (projectmessage::canadd(logged_user(), active_project())) { ?>         <li><a href="<?php echo get_url('message', 'add') ?>"><?php echo lang('add message') ?></a></li> <?php } // if ?>          <li class="header"><a href="<?php echo get_url('milestone', 'index') ?>"><?php echo lang('milestones') ?></a></li>         <li><a href="<?php echo get_url('milestone', 'calendar') ?>"><?php echo lang('view calendar') ?></a></li> <?php if (projectmilestone::canadd(logged_user(), active_project())) { ?>         <li><a href="<?php echo get_url('milestone', 'add') ?>"><?php echo lang('add milestone') ?></a></li> <?php } // if ?> <?php   // plugin hook   plugin_manager()->do_action('my_tasks_dropdown');   // plugin hook ?>       </ul>     </li>  <?php } // if ?> <?php } // if ?> <?php } // if ?>      <?php if(logged_user()->isadministrator()) { ?>     <li><a href="<?php echo get_url('administration') ?>"><?php echo lang('administration') ?></a>       <ul>         <li class="header"><a href="<?php echo get_url('administration', 'company') ?>"><?php echo lang('company') ?></a></li>         <li><a href="<?php echo get_url('company', 'edit') ?>"><?php echo lang('edit company') ?></a></li>         <li><a href="<?php echo owner_company()->getaddcontacturl() ?>"><?php echo lang('add contact') ?></a></li>         <li class="header"><a href="<?php echo get_url('administration', 'clients') ?>"><?php echo lang('clients') ?></a></li>         <li><a href="<?php echo get_url('company', 'add_client') ?>"><?php echo lang('add client') ?></a></li>         <li class="header"><a href="<?php echo get_url('administration', 'projects') ?>"><?php echo lang('projects') ?></a></li>         <li class="header"><a href="<?php echo get_url('administration', 'configuration') ?>"><?php echo lang('configuration') ?></a></li>         <li class="header"><a href="<?php echo get_url('administration', 'plugins') ?>"><?php echo lang('plugins') ?></a></li>         <li class="header"><a href="<?php echo get_url('administration', 'tools') ?>"><?php echo lang('administration tools') ?></a></li>         <li><a href="<?php echo get_url('administration', 'tool_mass_mailer') ?>"><?php echo lang('administration tool name mass_mailer' ) ?></a></li>         <li class="header"><a href="<?php echo get_url('administration', 'upgrade') ?>"><?php echo lang('upgrade') ?></a></li> <?php  // plugin hook   plugin_manager()->do_action('administration_dropdown');   // plugin hook ?>       </ul>     </li>     <?php } // if ?>      <li class="user"><a href="<?php echo logged_user()->getaccounturl() ?>"><?php echo lang('view') . ' ' . clean($_userbox_user->getdisplayname()) ?></a>       <ul>         <li><span><?php echo lang('account') ?>:</span></li> <?php  if (logged_user()->canupdateprofile(logged_user())) { ?>         <li><a href="<?php echo logged_user()->geteditprofileurl() ?>"><?php echo lang('update profile') ?></a></li>         <li><a href="<?php echo logged_user()->geteditpasswordurl() ?>"><?php echo lang('change password') ?></a></li> <?php  } // if ?> <?php  if (logged_user()->canupdatepermissions(logged_user())) { ?>         <li><a href="<?php echo logged_user()->getupdatepermissionsurl() ?>"><?php echo lang('update permissions') ?></a></li> <?php  } // if ?> <?php   // plugin hook   plugin_manager()->do_action('my_account_dropdown');   // plugin hook ?>       </ul>     </li>      <li><a href=#><img src="<?php echo image_url('icons/language.gif') ?>" /></a><ul>         <li><span><?php echo lang('select language') ?>:</span></li> <?php $base_language = config_option('installation_base_language', 'en_us'); $languages = array( $base_language => $base_language ); include(root . '/language/locales.php'); if ($handle = opendir(root . '/language')) {   while (false !== ($file = readdir($handle))) {     if ($file != "." && $file != "..") {       if (array_key_exists( $file, $locales)) {         $languages[$file] = $locales[$file];       }     }   }   closedir($handle); } foreach( $languages $locale => $desc ) {   echo '<li><a href="' . get_url('dashboard', 'index', array('language' => $locale) ) . '" >' . $desc . '</a></li>'; } ?>       </ul>     </li>     <li><a id="logout" class="js-confirm" href="<?php echo get_url('access', 'logout') ?>" title="<?php echo lang('confirm logout') ?>"><?php echo lang('logout') ?></a></li>   </ul> </div> <?php trace(__file__,'end'); ?> 

as can see shows single image. , can't seem figure out how change adjust language.

i end these results:

result nl

result en

in language file menu options showed, , can change these. changed them using sprite flag.

enter image description here

sprite language menu option (locales.php):

<?php  $locales = array(   'bg_bg' => 'bulgarian (bulgaria)',   'cz_cz' => 'czech',   'da_dk' => '<img src="images/blank.gif" class="flag flag-dk" alt="danish" /> danish',   'de_de' => '<img src="images/blank.gif" class="flag flag-de" alt="german" /> german',   'el_gr' => 'greek',   'en_us' => '<img src="images/blank.gif" class="flag flag-gb" alt="english" /> english',   'es_ar' => 'spanish (argentina)',   'es_es' => '<img src="images/blank.gif" class="flag flag-es" alt="spanish" /> spanish',   'es_mx' => 'spanish (mexico)',   'fi_fi' => '<img src="images/blank.gif" class="flag flag-fi" alt="finnish" /> finnish',   'fr_fr' => '<img src="images/blank.gif" class="flag flag-fi" alt="finnish" /> finnish',   'hu_hu' => 'hungarian (hungary)',   'hu_if' => 'hungarian (informal)',   'is_is' => '<img src="images/blank.gif" class="flag flag-is" alt="icelandic" /> icelandic',   'it_it' => '<img src="images/blank.gif" class="flag flag-it" alt="italian" /> italian',   'lt_lt' => 'lithuanian (lithuania)',   'nl_nl' => '<img src="images/blank.gif" class="flag flag-nl" alt="dutch (nederlands)" /> dutch',   'no_nb' => '<img src="images/blank.gif" class="flag flag-no" alt="norwegian" /> norwegian',   'pl_pl' => 'polish (poland)',   'pt_br' => 'portuguese (brazil)',   'pt_pt' => 'portuguese (portugal)',   'ru_ru' => '<img src="images/blank.gif" class="flag flag-ru" alt="russian" /> russian',   'sl_si' => 'slovenian (slovenia)',   'sv_se' => 'swedish (sv_se)',   'tr_tr' => 'turkish (turkey)',   'vn_vn' => 'vietnamese',   'zh_cn' => '<img src="images/blank.gif" class="flag flag-cn" alt="chinese" /> simplified chinese', );  ?> 

css:

.flag {     width: 16px;     height: 11px;     background:url(/images/flags.png) no-repeat }  .flag.flag-cn {background-position: -16px 0} .flag.flag-de {background-position: -32px 0} .flag.flag-dk {background-position: -48px 0} .flag.flag-es {background-position: 0 -11px} .flag.flag-fi {background-position: -16px -11px} .flag.flag-gb {background-position: -32px -11px} .flag.flag-is {background-position: -48px -11px} .flag.flag-it {background-position: 0 -22px} .flag.flag-nl {background-position: -16px -22px} .flag.flag-no {background-position: -32px -22px} .flag.flag-ru {background-position: -48px -22px} 

`

now have tried multiple things. can not seem right code. want change icon (dutch flag in images) change correct language flag. favoured using sprite, if much, make seperate images. need figuring out code make work.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -