151 replies [Last post]
firewing1's picture
Offline
Joined: 07/07/2009
Juice: 126
hook_nodeapi

It turns out hook_nodeapi is what we are looking for... This sample works for displaying the nodes:

<?php
/**
* Implementation of hook_nodeapi().
*/
function custommod_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch (
$op) {
    case
'load':
     
$translations = translation_node_get_translations($node->nid);
     
$language = language_default();
     
$sourcenode = $translations[$language->language];
     
$items = db_fetch_object(db_query('SELECT model, list_price, cost, sell_price, weight, weight_units, length, width, height, length_units, pkg_qty, default_qty, unique_hash, ordering, shippable FROM {uc_products} WHERE vid = %d', $sourcenode->nid));
      if(
$items) {
        foreach(
$items as $field => $value) {
         
$node->$field = $value;
        }
      }
      break;
  }
}
?>

Description of the code: First, it looks up all translations for the node being loaded, which includes the original language, and then determines the site's default language. It then uses the same query that uc_product.module performs to retrieve product data, but uses the node ID of the node in site's default language and overrides the current node's ubercart product values with those from the source node.

It works well, however there are three problems:

  1. Editing a translated product will load the correct values, but clicking "Save" will still store the redundant data.
  2. Adding to this function to also handle the update and insert events (so it only saves product info non-redundantly in the source node) will mean that if a node is deleted, all translated nodes must be deleted with it (as their product data would have gone missing, rendering them useless).
  3. If all the above is done it's pretty much the same thing as i18n sync, so may as well use that. As a bonus i18n sync also handles the CCK fields of your choice, which this method cannot do. It would have to use either all CCK fields, or use manually-programmed queries and either of these choices are not very useful.

CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
pretty ugly

Having multipule copys of the same data is ugly. The translations are just for display purposes really so keeping and sync'ing all that redundant data is going to error prone and worse will be hard to upgrade and maintain in the future.

If I were forced to do a multi-lingual shop right now I'd have a separate shop for each language with separate DBs and use Google Analytics to do the reporting. Keep it clean until a good solution comes about.

The ideal solution would be to just translate the strings before they are displayed and provide a simple interface which just lists the strings and their equivalents (filtering by language). I guess attributes and options aren't going to change much so the t() function could be used on them all. Perhaps it could be used for everything...?

Why aren't all the reports using SKU instead of NID? This would then fix the multi-node problem, no?

I'd like to get over to Paris (I'm in Berlin). The trip isn't a problem but hotel for 4 nights will be too pricey Sad

Uberdevelopment www.tsd.net.au/blog

Jurgen8e's picture
Offline
Joined: 10/02/2008
Juice: 87
Hi, In this thread is read

Hi,

In this thread I read about product translations.
But what about orders, an order is made in a language. The aftersale-mails must also be in that specific 'order made'-language.

For multi domain support I added a column to the 'order'-table to know where the order is placed.
I´m thinking to also do this for the language of an order.

Just want to notice this.

Jurgen
www.cardKeyfinder.com

jorditr's picture
Offline
Getting busy with the Ubercode.
Joined: 10/31/2007
Juice: 256
Re: i18n issues i D6/UC2 for Multilingual sites

I've always been very worried about that. My impression is that we need an only and unique node for every product (and SKU), so we need a mechanism for having a title box for every active language, another body box for every language and a consistent way to translate attributes and ubercart details. Only Ubercart might be capable to create a box for every language and replace them on every node display or listing according the current language.

CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
NO, the more I think about

NO,
the more I think about it the more I'm conviced now that 1 Product = 1 Node is a bad idea. Its the idea that has created this mess in the first place. Heres the example:

1 Product with 2 attributes (2 Colours and 3 Sizes) = 2 x 3 SKUs = 6 SKUs

Now you have to realaise that 1 SKU = 1 Product to all the Ubercart processes (or should) _NOT_ node id. The grouping of all these products together into 1 Node ID is a conceptual grouping for displaying to the customer as when you go to a shoe shop and you just see one shoe in the window in each style not all the size+colours, they fetch the exact shoe for you once you have told them your size and colour preference.

At the end of the day Checkout, Stock tracking, Physical product to ship is:

SKU = Sneeker (Product type) + Red (Colour) + Large (size)

So if we have it in out heads that the SKU is the real product and the Node ID is just for display purposes we can de-couple the 2 and just look up (many-to-many table in DB) the Node ID for the SKU when ever we need to display a representation of the product to the
end user.

Thus Drupal can do its normal node translation trick and Ubercart and live in peace with this side-by-side. What it boils down too is: when someone adds something to their cart they add an SKU _not_ a Node ID.

Anyone have a use-case where this falls down?

Uberdevelopment www.tsd.net.au/blog

Jurgen8e's picture
Offline
Joined: 10/02/2008
Juice: 87
The solution and the hack

Hi,

CpILL, I think your solution is better.
But many people want a solution(hack) fast for there existing systems, therefore I follow drupalina.

Maybe we can follow both ideas, the solution and the hack.

For the hack, I´m just going to use language sections module and extra cck fields (going to change node_load()).
Any helps for the multi-language URL problem are welcome.
/de/schlusselfinder -> de/node/72
/nl/sleutelvinder-> nl/node/72

Jurgen

jorditr's picture
Offline
Getting busy with the Ubercode.
Joined: 10/31/2007
Juice: 256
Re: The solution and the hack

About Drupalina and CpILL discussion on which strategy to follow, I could not agree more with CpILL schema: one SKU, one node. It's plain simple. But I realize that Drupalina aproach would offer faster results. Maybe it's time to fork Ãœbercart...

jorditr's picture
Offline
Getting busy with the Ubercode.
Joined: 10/31/2007
Juice: 256
Re: Re: The solution and the hack

BTW, and talking about multilinguality support on Ãœbercart: am I the only one who the variable translation method used by Ãœbercart does not work at all?

Why Ãœbercart is using?:

<?php
    variable_get
('uc_catalog_name', t('Catalog'))
?>

...and I have to replace it to (please, look at the position of the "t" function):

<?php
    t
(variable_get('uc_catalog_name', 'Catalog'))
?>

...on every place it appears because it never works to me the way standard Ãœbercart is released. And it happens plenty of times along Ãœbercart code.

Am I really the only one with that trouble on multilingual Ãœbercart implementations?

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3300
jorditr wrote: BTW, and
jorditr wrote:

BTW, and talking about multilinguality support on Ãœbercart: am I the only one who the variable translation method used by Ãœbercart does not work at all?

Why Ãœbercart is using?:

<?php
    variable_get
('uc_catalog_name', t('Catalog'))
?>

...and I have to replace it to (please, look at the position of the "t" function):

<?php
    t
(variable_get('uc_catalog_name', 'Catalog'))
?>

...on every place it appears because it never works to me the way standard Ãœbercart is released. And it happens plenty of times along Ãœbercart code.

Am I really the only one with that trouble on multilingual Ãœbercart implementations?

Ubercart is doing the right thing here. t() is not supposed to be used to translate variables like you have done. Variables in the variable table are handled by i18n using a different mechanism - see the Ubercart FAQ and the i18n documentation for details. The only question should be is whether Ubercart has added *all* the variables to the $conf array so that i18n can handle them properly. That can only be determined if you try it out and report any problems in the drupal.org issue queue.

<tr>.
jorditr's picture
Offline
Getting busy with the Ubercode.
Joined: 10/31/2007
Juice: 256
Hi TR, I'm sorry, I'm not

Hi TR,

I'm sorry, I'm not talking at all about i18n variables, I'm simply talking about the t() function, and the way that it's placed on all variable_get() function in Ãœbercart. I've developed 4 Ãœbercart sites, with different versions of drupal (5 and 6), different hosting, and PHP configurations and always had the same problem. The only thing I know is that if I change the t() funcion it works properly. Maybe I'm the only one having that problem...

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3300
Re: Hi TR, I'm sorry, I'm not

I understood exactly what you meant. There have been many threads about this issue. Your use of t() in that manner violates Drupal coding standards - t() is not to be used to translate variables, it is only for string literals. Translating variables has always been a problem because of this, but no module other than Ubercart makes extensive use of variables, so this translation problem was largely unaddressed in Drupal. The solution is provided by the i18n module, and patches to Ubercart were made so that i18n was informed about all Ubercart variables. Then patches to i18n were made because it was doing the wrong thing. This should all be working now in RC7 with the -dev version of i18n. Follow the links in the FAQ that I mentioned to learn more.

<tr>.
depcam's picture
Offline
Joined: 10/09/2009
Juice: 2
Re: Re: Hi TR, I'm sorry, I'm not

I just tried updating to RC7 and the -dev version of i18n and it won't change anything.

jorditr's picture
Offline
Getting busy with the Ubercode.
Joined: 10/31/2007
Juice: 256
Re: Re: Hi TR, I'm sorry, I'm not

Hi TR. Thanks for your comments. I know that using t() that way "violates drupal coding standards", but I've used on every ecommerce with ubercart I've made, it was the only way I realized to have it working. After all, my customers are not going to change the text of ubercart buttoms twice a day... Smiling

I have to admit that I didn't realized that they could be translated using i18n variables method. Thanks a lot for pointing me to that page. All in all, I have to admit that I don't like that way, Ãœbercart doesn't document the name of things to translate very well, and, what would happen if I'm not using i18n module on some site that would work with drupal 6 core multilingual support? On some type of hosting it's not easy to have a drupal6 site working with many, many modules. In any case, I admit that the solution you propose is more proficient.

tomsm's picture
Offline
Joined: 03/02/2009
Juice: 17
Re: Re: Re: Hi TR, I'm sorry, I'm not

I just installed ubercart 2.

I have a custom CCK content type with CCK fields like price, art. number etc.
These fields are synchronized correctly between translations:
for ex. if I change the price in one language, the other languages are updated correctly.

I added my cck content type to ubercart by creating a class. The new fields like SKU and sell price are not updated correctly between translations.

The default uc_product content type has the same problem.
After I created an English product node I selected translate. The fields SKU and sell price are set to default, empty and 0.00. Normally, the field values of the source node should be displayed.

So my D6 installation works properly regarding i18_sync en CCK, but Ubercart does not.

splash112@drupal.org's picture
Offline
Joined: 03/31/2008
Juice: 413
CpILL wrote: NO, the more I
CpILL wrote:

NO,
the more I think about it the more I'm conviced now that 1 Product = 1 Node is a bad idea. Its the idea that has created this mess in the first place. Heres the example:

I totally agree. It does not make any sense when you start doing multilangual, although it might make life easier with classes too.

CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
Re: CpILL wrote: NO, the more I

what will make life easier with classes?

Uberdevelopment www.tsd.net.au/blog

splash112's picture
Offline
Joined: 02/06/2009
Juice: 4
Re: Re: CpILL wrote: NO, the more I

ah sorry, was typing in overdrive...

I just meant to say that the one node = one product has quite a lot of complications all over. Just a single unique identifier (like SKU), but could be anything, which links to a node by a many-to-many table would do the trick best. This would, probably, also make life with classes and product kits a little easier.

Downside could be that we cannot do the CCK product information integration, as I believe these are uniquely used by nodes. A separate data node for the product data could be useful there, but would also be messy with many to many relations over multiple id's per node (nid, rid).

Difficult problem, but I guess many people in the Drupal community are struggling with. Maybe best to wait out the 2.0 release and check which way the crowd goes for 3.x.

Thanks
Mark

papricus's picture
Offline
Joined: 10/17/2009
Juice: 2
Avoiding syncronization of ratings

Furthermore, "one node = one product" means you don't have to synchronize voting API in between the languages.

Does anyone have an idea how I can avoid having differnt rating values in different languages?

redben's picture
Offline
Joined: 03/02/2009
Juice: 19
Language Sections

Just to share my workaround to this issue,( until node produt seperation is implemented) I used language_sections.
It does not add any new node or fields. In fact it adds an input foramt. For example, to translate a nodes body you put this in the text area
===en===
This is the english description
===fr===
Ceci est la description en francais

Oh, and don't forget to make your product nodes language neutral.

It works as expected and i have only one node per product with all the trabslations in the corresponding field.
For more info http://drupal.org/project/language_sections

Well, until product and node are separated...

CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
Re: Language Sections

@redben, so how do node titles work? or product attributes? I guess this type of solutions is the best bet at the moment.

Uberdevelopment www.tsd.net.au/blog

arpieb's picture
Offline
Joined: 10/28/2009
Juice: 81
Catalog translations

I don't know if this has already been beaten into the ground (or maybe I'm stating the obvious), but I didn't see any universally-blessed solutions above for translation of the catalog terms using i18n. I'm building a site that is initially going to be launched in English and German (English the default language), and possibly more Euro languages in the future. After setting up the Catalog vocabulary using Translation Tables, I discovered that UC wasn't handling my i18n data.

After poking around, I found a post at http://drupal.org/node/313268 by hades666evil that leveraged the i18nstring module's tt() method for "taxonomy translation." All I did to start down the road to correcting this was to invoke the following at the top of uc_catalog.module:

module_load_include('module', 'i18nstrings');

and in the function _uc_catalog_navigation() changed the construction of the catalog list item to use the tt() method when adding the branch name:

...
  $lis = array();
  $expand = variable_get('uc_catalog_expand_categories', FALSE);
  // arpieb - added tt() call
  $link = l(tt('taxonomy:term:'.$branch->tid.':name', $branch->name) . $num_text, $branch_path);
...

Now I just need to address the block title, breadcrumb, and sub-term listings in the same way, but at this point my site's catalog block menu is now using the i18n translations.

Maybe something like this could be added to the next release of UC - namely checking for the existence of an active i18n installation and if found, use the tt() method from it to translate catalog terms?

As for product translation - it is definitely a daunting task, and I plan on exploring all avenues presented in this thread. Thanks for the great suggestions!

And for what it's worth, I agree that products should be in a single node for inventory/pricing/image/SKU consistency with perhaps certain fields able to be flagged to be translatable via i8n like attributes, descriptions, names, etc.

-R

GiorgosK's picture
Offline
Joined: 07/05/2009
Juice: 45
Re: Catalog translations

while language_sections might seem like a good idea

you are forced to use plain text areas as there is no support for wysiwyg (not yet at least)
and there seems to be some issues with search engines indexing the default language only
http://drupal.org/node/361069

CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
yeah, what you really want

yeah,

what you really want is for a different path and the language of the page to be set in the tag. All solutions here come with compromise.

Uberdevelopment www.tsd.net.au/blog

totsubo's picture
Offline
Joined: 11/12/2009
Juice: 164
Re: yeah, what you really want

Forgive my newbie question. I'm new to Drupal/Ubercart and just starting now to use D6/UC2 to set up a bilingual site/shop.

Does this mean that UC won't offer full/complete i8ln support and I will have problems trying to show my products in two languages?

Worse, there seems to be no solution in sight, even D7/UC3 won't solve the issue?

What's the best I can hope for with current state of affairs?

GiorgosK's picture
Offline
Joined: 07/05/2009
Juice: 45
Re: Re: yeah, what you really want

@totsubo
For multilingual d6/uc2 this thread is probably your best bet, it outlines all the possible workarounds ...
Find one that suits your needs and implement it, since the problems are inherent to the core of UC2 and thus not easily fixable ...

However UC3 is probably going to have a lot of changes under the hood and will most definitely solve the issue of multilinguality as well, for more info on UC3 follow the discussions
here http://www.ubercart.org/forum/development/10901/ubercart_3x_battle_plans
and http://d7uc.org/

totsubo's picture
Offline
Joined: 11/12/2009
Juice: 164
Re: Re: Re: yeah, what you really want

@GiorgosK: Thanks for the comment. Wish UC3 were here now but it's far away. I have to make do with what we have Sad

I've followed firewing's blog post on how to have a multilingual UC and it helped with a few issues but not all. Specifically I am not able to get the Catalog to translate. When I switch languages my whole catalog disappears.

Can anyone point me to a resource that describes how to translate the Catalog? Any approach is OK, either using the translation interface or as firewing is doing, using a View.

I promise to type of a detailed blog post with step-by-step instructions if I can ever get it working!

firewing1's picture
Offline
Joined: 07/07/2009
Juice: 126
Node translation

Just for the record, totsubo and I have been communicating off this thread and we were able to fix the problem. For others with the same issue, the cause is the content selection mode at (browse to /admin/settings/language/i18n). Unless "All content. No language conditions apply." is selected, untranslated content will not appear on the catalog (it's the same behaviour for other/"regular" node types as well). So in other words either content selection must be disabled or the product nodes have to be translated in order to populate the catalog correctly.

totsubo's picture
Offline
Joined: 11/12/2009
Juice: 164
Re: Node translation

firewing beat me to the punch. I was waiting to figure everything out before posting back Smiling

In short, I had not translated my Products. So when I switched to another language, the Catalog could not find any Products in that language and hence did not display at all. Once I had translated my Products the Catalog worked exactly as expected!

Now I am trying to figure out how to translate Ubercart's various pane's titles/headers. I'm trying to do this through the .po files but it doesn't seem to be working.

firewing suggested I use the Translate Interface, and of course that works. However I would like to contribute my translation back to the community, so I need to do a bit of research on how to submit translations. Pointers appreciated Smiling

redben's picture
Offline
Joined: 03/02/2009
Juice: 19
Re: yeah, what you really want

@CpILL #69
I don't know but for me i get different paths :
en: /my-product
fr: /fr/mon-produit

For your question regarding single line fields you just use the same syntax. see http://drupal.org/node/272464

Another thing to note is in teasers, teaser text might not show up for all languages if you rely on default trimming (post settings). For example if your trimming settings are on 200 chars, and your second language section starts at 201, the teaser for that language would be empty.
You should manually add the <!--break--> at the point you want so as not to have unexpected results.

As you say every solution comes with a compromise

selinav's picture
Offline
Joined: 08/17/2009
Juice: 155
Hello, This discuss is

Hello,

This discuss is interesting but I'm lost and I don't really know how to do to translate my ubercart shop and to have no problem with the stocks, attributes and so on.

Currently I have a shop where the default language is french. All of my products are referenced.
But, before to translate it, I'd like to be sure on the way to do to have not problem with stock.

Can you resume me your method to translate it, please.

Thanks in advance.

totsubo's picture
Offline
Joined: 11/12/2009
Juice: 164
Re: Hello, This discuss is

firewing has a good write up on one method of dealing with some of the issues a translated UC can create here: http://www.firewing1.com/node/27

As for dealing with stock issues, I'm not sure if that is a problem or not using the above method. Test it out and see. If stock issues still exist I can't recommend a solution though this thread might have some solutions already mentionned.

selinav's picture
Offline
Joined: 08/17/2009
Juice: 155
Re: Re: Hello, This discuss is

thanks for the reply, it's good for the translation but if a product have stock when I traduce it has no stock inventoried.

How do you adjust the stock for all languages when you translate a node and when an order is confirmed?

(the stock module is installed)

firewing1's picture
Offline
Joined: 07/07/2009
Juice: 126
Synchronizing translated product nodes

On my blog, I show how to enable synchronization of product data (it's the second "Problem:" heading) - although stock isn't there by default, I would imagine you could add it to the list of items to synchronize by checking the output of print_r($node) in node-product.tpl.php and then adding to the $fields['uc_products']['#options'] array.

selinav's picture
Offline
Joined: 08/17/2009
Juice: 155
Re: Synchronizing translated product nodes

thanks Firewing for your answer, even if I synchronize the stock in my translated node, when a customer order a product it take down of the stock only in its language because 1 node = 1 product in ubercart.

For example.
My product A have 6 unit in stock in french.
I translate my product A in English, I have 6 products A in stock for the english.

If a customer order 3 product A in french.

My inventory will be
3 product A in french
6 product A in english.

How to update the stock in english to have 3 products also in english after the order of a customer in french?

firewing1's picture
Offline
Joined: 07/07/2009
Juice: 126
Stock unavailable in $node

I just checked, it looks like quantity (to add to cart) is available from $node, but not the current stock which is why it's not working even with i18nsync. So unfortunately it looks like you'll need to develop a custom module that hooks into Ubercart to manually update the stock information in the database to get this working.

I will be looking into this in the near future since I need this functionality as well, but that's only in a month or so.

selinav's picture
Offline
Joined: 08/17/2009
Juice: 155
Re: Stock unavailable in $node

Ok, if I develop this module what is the best moment to execute it?

-When the order is confirmed and when it cancelled?

Is somebody could help me to develop it?

Thanks in advance

firewing1's picture
Offline
Joined: 07/07/2009
Juice: 126
Ubercart hooks

I think it would be best if you use an order hook to update all a product's nodes when an order is submitted. hook_order_product_alter() looks like a good choice, but there may be a better one. A full list of hooks for UC2 is available here: http://api.ubercart.org/api/group/hooks/2

Essentially, your module will first have to determine if the product being ordered is a translation or not. If so, it must find the original product node, set the correct stock, and then update all translations accordingly. If it is not a translated node (meaning it is the original product node), then simply update all translations accordingly.

selinav's picture
Offline
Joined: 08/17/2009
Juice: 155
thanks for your reply. I

thanks for your reply.

I have seen also the hook_uc_stock_adjusted.

Is this hook called only when the stock is adjusted by the admin or also when an order is confirmed?

When the hook_order_product_alter is called? (when the order is passed or when it is confirmed?)

How ubercart adjust the stock in the order process?

firewing1's picture
Offline
Joined: 07/07/2009
Juice: 126
selinav wrote: thanks for
selinav wrote:

thanks for your reply.

I have seen also the hook_uc_stock_adjusted.

Is this hook called only when the stock is adjusted by the admin or also when an order is confirmed?

When the hook_order_product_alter is called? (when the order is passed or when it is confirmed?)

How ubercart adjust the stock in the order process?

Although testing it in a simple custom module (just have it echo "FOOBAR" or something) would be the best way to test it, but from the description hook_uc_stock_adjusted seems to run whenever any of the stock is modified, be it by and order or by the site administrators. hook_order_product_alter would be a good choice, but if I remember correctly &$product doesn't contain the stock information, so you'll have to grab the nid from $product and then operate on the DB manually.

selinav's picture
Offline
Joined: 08/17/2009
Juice: 155
Re: Synchronizing translated product nodes

I have a field "Reseller price" which has name [reseller_price] when I doing a print_r($node), but if I added it in the custommod, nothing happend

<?php
/**
* Implementation of hook_i18nsync_fields_alter().
*/
function custommod_i18nsync_fields_alter($fields, $type) {
$fields['uc_products']['#title'] = 'Products';
// These values were found by doing a print_r($node) in node-product.tpl.php
$fields['uc_products']['#options'] = array (
'model' => 'SKU',
'list_price' => 'List Price',
'cost' => 'Cost',
'sell_price' => 'Sell Price',
'weight' => 'Weight',
'weight_units' => 'Weight Units',
'length' => 'Length',
'width' => 'Width',
'height' => 'Height',
'length_units' => 'Length Units',
'pkg_qty' => 'Quantity',
'default_qty' => 'Default quantity to add to cart',
'reseller_price' => 'Reseller price'
);
}
?>

How should I do to get the value of the reseller price and the attributes. When I've doing a print_r($node),
this information are in the object [referencing_node]=> array [attributes], [referencing_node]=> [reseller_price]

Please help me

firewing1's picture
Offline
Joined: 07/07/2009
Juice: 126
CCK
selinav wrote:

I have a field "Reseller price" which has name [reseller_price] when I doing a print_r($node), but if I added it in the custommod, nothing happend

How should I do to get the value of the reseller price and the attributes. When I've doing a print_r($node),
this information are in the object [referencing_node]=> array [attributes], [referencing_node]=> [reseller_price]

Please help me

This method only works for the node type's fields (such as with CCK), but not with attributes... Attributes become much more complex since they have multiple options and each of those options may need to be translated. If the reseller price is just a text field, I would try removing the attribute and adding a text CCK field to the node, as this you would be able to sync correctly.

selinav's picture
Offline
Joined: 08/17/2009
Juice: 155
Re: CCK

Is there somebody which success to translate / get the information of the attributes when a node is translated?

How can I do it?

////////////////////////EDIT//////////////////////

I have succeed, I don't know if it is the best way. The code can probably improved.

My code

<?php
function maj_attributs_nodeapi(&$node, $op){
       
$type = $node->type;
   
$types = array('product' => 1);
   
       
//is the node a product content type?
   
if (isset($types[$type])) {
       
$mon_type = TRUE;
    } else {
       
$mon_type = FALSE;
    }   

   

//if the insert node is a translation, we add the attributes and options
   
if($mon_type==TRUE && $op=='insert'){
       
       
$nid=$node->nid;
       
       
// is the created node is a translation ?
       
$req="SELECT tnid FROM {node} n WHERE nid=%d";
       
$result=db_query(db_rewrite_sql($req), $nid);
        while (
$data=db_fetch_object($result)){
           
$tnid=$data->tnid;
        }
       
        if(
$tnid==$nid){
           
$traduction=0;
        } else {
           
$traduction=1;
        }
       
       
//if it is a translation ...
       
if($traduction==1){
           
           
//get the information about the base nid ( tnid)
           
            //table uc_product_attributes
           
$req1="SELECT distinct upa.* FROM {uc_product_attributes} upa, {node} n WHERE upa.nid=%d";
           
$result1=db_query(db_rewrite_sql($req1), $tnid);
            while (
$data1=db_fetch_object($result1)){
               
//insert in the table
               
$aid=$data1->aid;
               
$label=$data1->label;
               
$ordering=$data1->ordering;
               
$default_option=$data1->default_option;
               
$required=$data1->required;
               
$display=$data1->display;
               
               
table='uc_product_attributes';
               
$record=new stdClass();
               
$record->nid=$nid;
               
$record->aid=$aid;
               
$record->label=$label;
               
$record->ordering=$ordering;
               
$record->default_option=$default_option;
               
$record->required=$required;
               
$record->display=$display;
               
               
drupal_write_record($table, $record);
               
            }
           
           
//table uc_product_options
           
$req2="SELECT distinct upo.* FROM {uc_product_options} upo, {node} n WHERE upo.nid=%d";
           
$result2=db_query(db_rewrite_sql($req2), $tnid);
            while (
$data2=db_fetch_object($result2)){
               
//insert in the table
               
$oid=$data2->oid;
               
$cost=$data2->cost;
               
$price=$data2->price;
               
$weight=$data2->weight;
               
$ordering=$data2->ordering;
               
               
$table='uc_product_options';
               
$record=new stdClass();
               
$record->nid=$nid;
               
$record->oid=$oid;
               
$record->cost=$cost;
               
$record->price=$price;
               
$record->weight=$weight;
               
$record->ordering=$ordering;
                               
               
drupal_write_record($table, $record);
               
            }
           
           
//table uc_product_adjustments
           
$req3="SELECT distinct upa.* FROM {uc_product_adjustments} upa, {node} n WHERE upa.nid=%d";
           
$result3=db_query(db_rewrite_sql($req3), $tnid);
            while (
$data3=db_fetch_object($result3)){
               
//insert in the table
               
$combination=$data3->combination;
               
$model=$data3->model;
               
               
$table='uc_product_adjustments';
               
$record=new stdClass();
               
$record->nid=$nid;
               
$record->combination=$combination;
               
$record->model=$model;
                                               
               
drupal_write_record($table, $record);
               
            }           
        }       
    }   
}

?>
heyyo's picture
Offline
Joined: 05/17/2009
Juice: 36
Re: Re: CCK

Why the patch from cha0s has not been comitted or anyone worked on it !!!

http://drupal.org/node/488452

Everyone is asking for a patch for the translation of:

Attributes/Adjustments
Product features (in core - files & roles)
Stock
Google Checkout
Quote
UPS
USPS
Weight Quote

Cha0s provided one 6 months ago !!! And no one gave feedback on its work !!
I really don't understand...

Explanations are welcome...

keereel's picture
Offline
Joined: 01/24/2009
Juice: 21
Re: Re: Re: CCK

I think, that patch is not actual for now, isnt it? I need this features in my project, but I'm not sure about. Patch date is june 09, i18n latest release date is april 10.

redben's picture
Offline
Joined: 03/02/2009
Juice: 19
Search engines ?

@GiorgosK #68
From the thread you link, it is reported that it has problems with drupal's search engine, not search engines in general, or does it ?
As for the wysiwyg point, you are right.

Another option i have been thinking about, is to mimic what might be done in ubercore, Have product nodes only hold the basic data (name price sku..etc), and create a content type product presentation that has a node reference field for referencing products. Then some kind of formatter for products has to be made so as one can have the price, add to cart...etc on the "product presentation" node.

xacobe's picture
Offline
Joined: 06/16/2009
Juice: 46
Translate Orders Status

Hi,

There is a lot of information about to build a multilingual site but I couldnt found anything about how to translate the orders statuses title. This is very important since the costumer cant see on his language this value information.

Anyone did it?

Thanks

firewing1's picture
Offline
Joined: 07/07/2009
Juice: 126
Re: i18n issues i D6/UC2 for Multilingual sites

That's a great patch, although it doesn't really handle the "translation" of attributes - it will copy them to the translated product however. I think we need to wrap the attribute name in a t() call before the attributes can be translated.

aacraig's picture
Offline
Joined: 01/15/2010
Juice: 19
Re: i18n issues i D6/UC2 for Multilingual sites

The conversation seems to have slowed down a bit, without a full resolution being arrived at.

I'm working on a drop in module to act as an interim (and very hacky) fix until this issue can be sorted out properly.

I've taken the opposite direction. I absolutely disagree that a translation constitutes another node. A translation is simply another view of the same data. Drupal has an improving, but still incomplete implementation of multiple language handling, and I think the biggest problem stems from the mistaken view that a translated node is somehow a separate entity from the original language node.

At any rate, I've got title, description and taxonomy showing up in the user's language when you install this module. To create a translation of a product's description or title, just edit in the desired language.

As this is for a site that must go live next week, I'll be finishing up the module and release it on the Drupal site as UC Localize next week.

If anyone wants to have a look at it now and give feedback, you can download the attachment and install. It is in extreme development mode, so only install on a dev site.

AttachmentSize
uc_localize.tar.gz 2.79 KB
aacraig's picture
Offline
Joined: 01/15/2010
Juice: 19
UC Localize - a drop in quick fix for internationalization issue

I've released UC Localize, which should act as an interim quick-fix to these issues.

The module attempts to sort out the most common issues (title, description translation, catalog and attribute translations) by simpy installing and enabling the module.

It can also serve as a starting point for more complex installations to build from for their own individual situations.

http://drupal.org/project/uc_localize

adrianmak's picture
Offline
Joined: 05/28/2008
Juice: 312
Re: UC Localize - a drop in quick fix for internationalization i

are there any depending modules to use it ?

For example, should I enable the Locale core module ? or install i18n module ?