Originally Posted by
torvista
Is it/was it not the case that the installation of an additional language would automatically copy the existing pre-english text (category/product titles and descriptions) to the new language fields?
I was sure this was what happened when I did this years ago, but it is not happening now...or am I completely confused!!
That should happen when the language is inserted, assuming 1) it actually gets inserted, 2) the $_SESSION['languages_id'] does not equal the newly installed languages_id and 3) the particular language record does not already exist for the category(ies)/product(s) in question... (see admin/languages.php file for more comprehensive review than provided below. Code below is shown from ZC 1.5.3.)
obtains records from languages table to see if the new code is already in the table, if it is, error message and skip the add of new/equivalent product and other associated actions, if not, then insert the language and perform action on the database.
Code:
$check = $db->Execute("select * from " . TABLE_LANGUAGES . " where code = '" . $code . "'");
if ($check->RecordCount() > 0) {
$messageStack->add(ERROR_DUPLICATE_LANGUAGE_CODE, 'error');
} else {
$db->Execute("insert into " . TABLE_LANGUAGES . "
(name, code, image, directory, sort_order)
values ('" . zen_db_input($name) . "', '" . zen_db_input($code) . "',
'" . zen_db_input($image) . "', '" . zen_db_input($directory) . "',
'" . zen_db_input($sort_order) . "')");
$insert_id = $db->Insert_ID();
This adds the categories for the new language and is still within the else statement above, with more language generation action following it.
Code:
// create additional categories_description records
$categories = $db->Execute("select c.categories_id, cd.categories_name,
categories_description
from " . TABLE_CATEGORIES . " c
left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
on c.categories_id = cd.categories_id
where cd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
while (!$categories->EOF) {
$db->Execute("insert into " . TABLE_CATEGORIES_DESCRIPTION . "
(categories_id, language_id, categories_name,
categories_description)
values ('" . (int)$categories->fields['categories_id'] . "', '" . (int)$insert_id . "',
'" . zen_db_input($categories->fields['categories_name']) . "',
'" . zen_db_input($categories->fields['categories_description']) . "')");
$categories->MoveNext();
}
Bookmarks