[ic] Localization of accessories

Mike Heins mikeh@minivend.com
Fri, 1 Dec 2000 21:17:39 -0500


Quoting Yuri Valentini (yv@libero.it.ERASETHIS):
> Hello!
> 
> Does anybody know how to localize the attributes of items in the product
> database?
> I have a database with items in different color and I would like to use
> color names in Italian or in English, based on the language selected.
> In the documentation I have read about something and inserted these lines in
> catalog.cfg:
> 
> UseModifier color_it
> Locale it_IT UseModifier color_it
> Locale en_US UseModifier color_en
> 
> where color_it is the default and color_en is to be used when the user
> chooses english.
> 
> I tryied to insert [item-accessories color_it] in the Italian basket page
> and [item-accessories color_en] in the English one, but probably I am doing
> something wrong, because the modifiers does not get preserved.
> 

That should work -- but if you order the item in English, it will lose
its value when you go to Italian. You would have to put in some custom
code in the basket like:

    [calc]
	    my $loc = '@@LANG@@';
	    my @attrib = qw/color size/;
	    my %check = qw/
			    it_IT it 
			    en_US en
			/;
	    # Over each item in cart
	    foreach my $item (@{$Carts->{main}}) {
		# and each attribute you are looking for
		foreach my $attrib (@attrib) {
		    # and each key of the item
		    for (keys %$item) {
			    my $one = $_;
			    next unless /^$attrib/;
			    next if /_$check{$loc}$/;
			    my $tmp = delete $item->{$one};
			    $one =~ s/_.*/_/;
			    $one .= $check{$loc};
			    $item->{$one} = $tmp;
		    }
		}
	    }
	    return;
    [/calc]

I don't think that is the best way to do it, though. The best way is
to use the capabilities of item-accessories to modify the field which
is used, and keep the modifier the same "color".

	[item-accessories color, [L]color_field[/L]]

Then:

Locale en_US color_field color_en
Locale it_IT color_field color_it

-- 
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <heins@akopia.com>

Light travels faster than sound. This is why some people appear bright
until you hear them speak. -- unknown