Forums / Addon Language Packs / installation of additional language and automatic copying of english database texts

installation of additional language and automatic copying of english database texts

Locked

Started by torvista on 11 Jan 2015, 10:36 PM · Views: 7,577

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
11 Jan 2015, 10:36 PM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

installation of additional language and automatic copying of english database texts

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!!

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

12 Jan 2015, 12:16 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: installation of additional language and automatic copying of english database texts

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.

$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) . "')");
[B]$insert_id [/B]= $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.

// 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();
}

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

13 Jan 2015, 10:11 PM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,880
Plugin Contributions:
7

Re: installation of additional language and automatic copying of english database texts

Thanks for the detailed answer, code from 1.53 does indeed work like that, but not 1.54:

http://www.zen-cart.com/showthread.php?215842-Insertion-of-an-additional-language-does-not-copy-existing-category-product-texts

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...