Re: Hello, I'm not a coder, but

jorditr's picture
Offline
Getting busy with the Ubercode.
Joined: 10/31/2007
Juice: 256
Re: Hello, I'm not a coder, but

Hi again, I've wanted to separate my last comments on different entries. Now I would like to comment that Drupalina entry.

I fully agree that such a i18n module would save us the day on multilingual shops,... and on many other types of sites Smiling

For been able to use it on node titles we should hide the node title (with excellent auto_nodetitle.module), and the use that field on views-like lists. But on übercart we'll have to hack the code on many places, because the title appearing on many lists as catalog, cart, order or checkout are not on "theme-like" funtions, but on many "core-like" übercart functions.

Having to hack Übercart code anyway, maybe one approach could be one that I've used on my last Übercart shop. I've created an alternative CCK plain-text-field called "field_spanish_title" that we can access at "content_field_spanish_title" table, a CCK field independent table because I've shared that field among all the product-node-type classes. Then the code on uc_cart.module is (you'll see all my hacked code between "// JTR" tags):

<?php
function uc_cart_view_form($form_state, $items = NULL) {
 
$form['items'] = array(
   
'#type' => 'tapir_table',
   
'#tree' => TRUE,
  );

 

$context = array(
   
'revision' => 'themed-original',
   
'location' => 'cart-subtotal',
  );
 
$i = 0;
  foreach (
$items as $item) {
   
$display_item = module_invoke($item->module, 'cart_display', $item);
    if (!empty(
$display_item)) {
     
$form['items'][$i] = $display_item;
     
$form['items'][$i]['image']['#value'] = uc_product_get_picture($display_item['nid']['#value'], 'cart');

     

// JTR - adding spannish name if required
     
$nom_spannish = db_result(db_query('SELECT field_spanish_title_value
                    FROM {content_field_spanish_title}
                    WHERE nid = %d'
, $display_item['nid']['#value']));
      global
$language;
      if (
$language->language == 'en') {
       
$nom_prod = $display_item['title']['#value'];
      } elseif (
$language->language == 'es' AND $nom_spannish ) {
       
$nom_prod = $nom_spannish ;
      } else {
       
$nom_prod = $display_item['title']['#value'];
      }
     
$description = $nom_prod . $display_item['description']['#value']; // JTR
     
$form['items'][$i]['desc']['#value'] = $description;

     

$form['items'][$i]['title']['#type'] = 'value';
     
$form['items'][$i]['description']['#type'] = 'value';

      if (empty(

$display_item['qty'])) {
       
$form['items'][$i]['qty'] = array(
         
'#value' => '',
        );
      }

     

$form['items'][$i]['total'] = array(
       
'#value' => uc_price($display_item['#total'], $context),
       
'#theme' => 'uc_cart_view_price',
      );
     
$i++;
    }
  }
?>

I don't know if that's the best way to approach that issue, but, at least, it works to me. I've prefered to display the code better that the patch to allow you to see the code solution. That means that for Übercart wouldn't be difficult at all to create an internal translation and loop through all the languages, saving, whay not, on a proper "uc_product_name_translation" table.

Well, at least, it's already working on my last Drupal/Übercart implementation. BTW, you'll also have to hack also "uc_cart_checkout_pane.inc" in order to swap node title with CCK translation node-title-like field on cart table.

i18n issues i D6/UC2 for Multilingual sites By: CpILL (150 replies) Mon, 05/11/2009 - 14:02