Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

countries_names


little.pm

Recommended Posts

Hi everyone,

 

I just posted a contribution that allows to have separate countries_names per language.

 

countries_names

 

Does anyone who is good at spanish does have the time and will to translate the countries names into spanish as I unfortunately don't speak nor even understand spanish :-)

 

Comments regarding if such contribution is usefull or not and what I might have missed out or how to improve it are highly appreciated as well.

 

regards

ralf

sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Link to comment
Share on other sites

Just posted an update with a minor bug fix.

 

regards

ralf

sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Link to comment
Share on other sites

  • 10 months later...

Just posted an update so the contribution now contains also the spanish countries names (wich where provided by Pablo Ferrer).

 

regards

ralf

sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Link to comment
Share on other sites

  • 1 month later...

Hello Ralf,

 

You made a nice contribution. It easy to install and well coded. Thanks! :)

 

Users with older versions of MySQL (IMHO all before 4.0) will see a silly behavior. German "Umlaut"-characters like "?", "?" and so on are sorted after the character "Z". The easiest way to solve the problem is the following piece of code. For that replace the old function "tep_get_countries" in catalg/includes/functions/general.php with this one:

 

  function tep_get_countries($countries_id = '', $with_iso_codes = false) {
	 global $languages_id;
   $countries_array = array();
   if (tep_not_null($countries_id)) {
     if ($with_iso_codes == true) {
       $countries = tep_db_query("SELECT cn.countries_name, c.countries_iso_code_2, c.countries_iso_code_3 from " . TABLE_COUNTRIES . " c, " . TABLE_COUNTRIES_NAMES . " cn  WHERE c.countries_id = '" . (int)$countries_id . "' AND c.countries_id = cn.countries_id AND cn.language_id = '" . $languages_id . "' ORDER BY countries_name");
       $countries_values = tep_db_fetch_array($countries);
       $countries_array = array('countries_name' => $countries_values['countries_name'],
                                'countries_iso_code_2' => $countries_values['countries_iso_code_2'],
                                'countries_iso_code_3' => $countries_values['countries_iso_code_3']);
     } else {
       $countries = tep_db_query("select countries_name from " . TABLE_COUNTRIES_NAMES . " where countries_id = '" . (int)$countries_id . "'AND language_id = '" . $languages_id . "' ORDER BY countries_name");
       $countries_values = tep_db_fetch_array($countries);
       $countries_array = array('countries_name' => $countries_values['countries_name']);
     }
   } else {
     $countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES_NAMES . " WHERE language_id = '" . $languages_id . "' ORDER BY countries_name");
     while ($countries_values = tep_db_fetch_array($countries)) {
       $countries_array[] = array('countries_id' => $countries_values['countries_id'],
                                  'countries_name' => $countries_values['countries_name']);
     }
   

// UMLAUT HACK
   $temp_countries_array = array();
foreach ($countries_array as $key => $data) {

  $sort_name = $data["countries_name"];
  $sort_name = str_replace (array("?","?","?","?","?","?","?"),
                            array("A","O","U","a","o","u","s"), $sort_name);
  
  $temp_countries_array[$sort_name] = $data; 
}
ksort($temp_countries_array);
$countries_array = array();
foreach ($temp_countries_array as $key => $data) {
  $countries_array[] = $data;
}
// END UMLAUT HACK	

}

   return $countries_array;
 }

 

 

Greets,

Johannes

Link to comment
Share on other sites

You made a nice contribution. It easy to install and well coded. Thanks! :)

Hello Johannes,

 

I am glad you like it.

 

Users with older versions of MySQL (IMHO all before 4.0) will see a silly behavior. German "Umlaut"-characters like "?", "?" and so on are sorted after the character "Z".

 

Yes, I do know the effect, but it does not only occur in german but also in all languages that use non standard ascii character sets but rather extended character sets. Think about accent acute in french for example.

 

The easiest way to solve the problem is the following piece of code. For that replace the old function "tep_get_countries" in catalg/includes/functions/general.php with this one:

 

I like your solution to the problem. However, a single solution for just one language can not fix the problem in general.

 

So I would prefer to go along the way with the languages themselves. Every language that we know of has an alphabet wich defines the sort order for each character.

 

So in the end we need to define a sort function, that sorts any list we give to it according to the predefined alpahbet for that language. The alphabet could be defined in the language file, eg. includes/languages/english.php or includes/languages/german.php.

 

The sort function gets the list we want to sort. It also gets the language ID for the language in wich (or according to that languages alphabet) we want to sort and a third argument stating a sort option, eg. ascending or descending.

 

Such function itself could be reused all over the place for other parts of the shop where a language dependend sort function could be of use, eg. to display and sort products options names.

 

The reason why I take the short time to write this down, is simply because I do currently not have the time to code such sort_function. May be you would have time and would want to code it : I would say to you as to everyone else: You're welcome, because its an open source project based on collabortaion :-)

 

 

regards

 

Ralf

sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Link to comment
Share on other sites

  • 1 year later...

Hi Ralf,

 

this looks exactly like what I needed.

 

I installed everything without problems yet just cannot figure out how to get the contribution "Zoneworld" to show "Deutschland" instead of "Germany" after "Versand nach:"

 

I do not know whether you need to see any of my files. I prepared the files of this contribution as well as my zones.php in catalog/includes/modules/shipping for download anyway.

 

looking forward to your comments.

Of course helpful hints from anybody else is more than welcome B)

 

Thanks for trying to help

Nala

Link to comment
Share on other sites

hi again,

 

just ignore my earlier text. My browser apparently now decided to show updated pages :thumbsup:

 

Perfect, this contribution was just what I needed. Thanks a lot !

 

Happy greetings

Nala

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...