Jump to content

[SOLVED] Flag order, can you switch?


Recommended Posts

If I for example have the flag order like:

English Spanish French

but want to have it like

French Spanish English

How should I do that? If I change the Language id in the database so the languages have the id in the order I want like

1 French 2 Spanish 3 English it arranges them correctly but it messes up among other things the cart so that when I have French selected the shopping cart is in English and vice versa.


I found where in the code is outputs the languages (see below) but I don't know enough PHP to alter the sorting.

Any help appreciated.


<!-- Block languages module -->


       {foreach from=$languages key=k item=language name="languages"}

               {if $language.iso_code != $lang_iso}getLanguageLink($language.id_lang, $language.name)}" title="{$language.name}">{/if}

               {if $language.iso_code != $lang_iso}{/if}

       {/foreach}


[removed]
   $('ul#first-languages li:not(.selected_language)').css('opacity', 0.3);
   $('ul#first-languages li:not(.selected_language)').hover(function(){ldelim}
       $(this).css('opacity', 1);
   {rdelim}, function(){ldelim}
       $(this).css('opacity', 0.3);
   {rdelim});
[removed]
<!-- /Block languages module -->

Link to comment
Share on other sites

I think this is a tricky one, though i'm not sure, as default english is 1, you may try on a fresh installation to remove the english language, then add spanish and then add english again.

Do it on a test first, not live!

Link to comment
Share on other sites

  • 1 month later...
  • 8 months later...
  • 2 years later...

For PS 1.5.4.1 I override the following class in classes/Language.php:

	public static function getLanguages($active = true, $id_shop = false)
	{
		if (!self::$_LANGUAGES)
			Language::loadLanguages();

		$languages = array();
		foreach (self::$_LANGUAGES as $language)
		{
			if ($active && !$language['active'] || ($id_shop && !isset($language['shops'][(int)$id_shop])))
				continue;
			$languages[] = $language;
		}

		usort($languages, function($a, $
		{
			//language iso_code in the desired order:
			$new_order = array("es", "en");
			foreach($new_order as &$value)
			{
				if ($a["iso_code"]==$value) return -1;
				if ($b["iso_code"]==$value) return 1;
			}
		});

		return $languages;
	}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...