Quote Originally Posted by DrByte View Post
One serious caveat: if you're corresponding with customers from your admin, all correspondence will happen in the selected language. So, if you're sending emails from your admin while in "English", then all your emails will go to the customer in English, even if the customer did their shopping in French or Spanish, or whatever. If you want the emails to be sent from the other language, you need to switch to that language first. But, if you haven't installed that language on your admin side, then ... well ... you won't be able to do that.
It's your customers who suffer when you don't install the admin-side language pack.
Thanks for the feedback, but I'm not sure it's a caveat. Your point is well taken, however, if person chooses not to install the languages on the admin side then he won't get the annoying error persisting across the top of the page.

On the other hand this code segment still checks to see if both parts exist, ie that they match in the both the site and the admin sections. It will only be ignored if the entire admin section is missing which would be the installers choice.

In my initial effort to get rid of the message, I simply created an empty directory and added the file that contained the following:

PHP Code:
<?php

exit("<div style='text-align:center; margin-top: 200px; color:red; font-weight: bold;'>There is no French admin section.<br>
      Use Back Button and select English.<br><br>
      "
);

?>
This does address the fact the admin language has not been installed and gets rid of the error message. This is one way to deal with missing admin sections.

With that said and taking your caveat/warning into consideration, we could modify my code segment as follows:
PHP Code:
// Check to see if each language directory and file exists.
// Create an Admin Languages Dropdown list of only those languages used by the admin interface.
$hide_languagestrue// first, initialize $hide_languages to get rid of all the crap in the else conditions that were at the end of this if statement
if ((basename($PHP_SELF) != FILENAME_DEFINE_LANGUAGE '.php') and (basename($PHP_SELF) != FILENAME_PRODUCTS_OPTIONS_NAME '.php') and empty($action)) {
  
$languages_array = array();
  
$languages zen_get_languages();
  if (
sizeof($languages) > 1) {
    
$languages_selected $_SESSION['language'];
    
$missing_languages=$missing_admin_languages='';
    for (
$i 0$n sizeof($languages); $i $n$i++) {
      
// Check for the catalog language directory and file
      
$test_directoryDIR_FS_CATALOG_LANGUAGES $languages[$i]['directory'] ;
      
$test_fileDIR_FS_CATALOG_LANGUAGES $languages[$i]['directory'] . '.php';
      
$isFile file_exists($test_file);
      
$isDir file_exists($test_directory);
      if ( !
$isFile || !$isDir ) {
        if ( !
$isFile && !$isDir ) { $missing_languages .= ' Missing directory: ' $test_directory ', and file: '$test_file;}
        else if ( !
$isDir ) { $missing_languages .= ' Missing directory: ' $test_directory;}
        else { 
$missing_languages .= ' Missing file: ' $test_file;}
      }
      
// Check to see if this language is also being used by admin interface.
      
$test_directoryDIR_WS_LANGUAGES $languages[$i]['directory'] ;
      
$test_fileDIR_WS_LANGUAGES $languages[$i]['directory'] . '.php';
      
$isFile file_exists($test_file);
      
$isDir file_exists($test_directory);
      if ( 
$isFile and $isDir ) {
        
$languages_array[] = array('id' => $languages[$i]['code'], 'text' => $languages[$i]['name']);
        if (
$languages[$i]['directory'] == $_SESSION['language']) {
          
$languages_selected $languages[$i]['code'];
        }
      } else if ( !
$isFile and !$isDir ) { // When both parts are missing it just means this language does not exist in the admin section 
        
$languages_array[] = array('id' => $languages[$i]['code'], 'text' => $languages[$i]['name'] . ' (not installed)');
      } else {
        if ( !
$isDir ) { $missing_admin_languages .= ' Missing directory: ' DIR_WS_ADMIN $test_directory;}
        else { 
$missing_admin_languages .= ' Missing file: ' DIR_WS_ADMIN $test_file;}
      }
    }
    if ( 
$missing_admin_languages !== '') {
      
$messageStack->add('MISSING ADMIN LANGUAGE FILES OR DIRECTORIES ...' $missing_admin_languages,'caution');
    }
    if ( 
$missing_languages !== '') { 
      
$messageStack->add('MISSING CATALOG LANGUAGE FILES OR DIRECTORIES ...' $missing_languages,'caution');
    }
    if(
sizeof($languages) > 1$hide_languages false;
  }

Now, the drop-down list is created but next to the missing language(s) it reads: French (not installed)

This might be the best of both worlds. It keeps the user informed about the languages missing in the admin side without creating the MISSING LANGUAGE FILES OR DIRECTORIES ... error, but still generates the error if there is file/directory mismatch.

In my clients case, he'll be responding in English regardless because he doesn't know any French.

In his case he is offering all his products in French although he doesn't speak it.

I suspect there are a lot of others that do the same thing, ie offer there products in languages they don't speak.

Anyway, good point and I think we'll have to look at how we handle our auto responses. (possibly a partial admin section to deal with the language email responses)

Thanks for the constructive criticism.