News:

Looking for documentation? Take a look on our wiki

Main Menu

Translate Multi Variant custom labels

Started by razor7, April 15, 2015, 14:15:26 PM

Previous topic - Next topic

razor7

Hi, I'm setting up my brand new store and using Multi Variant products (great new feature! saves a lot of time!).

Well, this new Multi Variant thing is great and also let you set custom labels for the frontend drop downs, but, when using it, the labels don't get translated (in case you wanto to do it).

I my case, I have put some labels with lang keys, like COM_VIRTUEMART_MGS_SUPPORT_PERIOD_ONE_MONTH and COM_VIRTUEMART_MGS_SUPPORT_PERIOD_THREE_MONTHS, added thoose strings to language overrides, but in frontend no dropdown labels got translated, so here is my patch for file customfields.php

The file is administrator/components/com_virtuemart/models/customfields.php in function displayProductCustomfieldFE arround line 836 insode case 'C' switch case. I'm using VM 3.0.7.4 and J! 3.4.1

change this:

if($soption->clabel!='' and in_array($soption->voption,self::$dimensions) ){
$rd = $soption->clabel;
if(is_numeric($rd) and is_numeric($elem)){
$text = number_format(round((float)$elem,(int)$rd),$rd);
}
//vmdebug('($dropdowns[$k] in DIMENSION value = '.$elem.' r='.$rd.' '.$text);
}


to this:

if($soption->clabel!='' and in_array($soption->voption,self::$dimensions) ){
$rd = $soption->clabel;
if(is_numeric($rd) and is_numeric($elem)){
$text = number_format(round((float)$elem,(int)$rd),$rd);
}
//vmdebug('($dropdowns[$k] in DIMENSION value = '.$elem.' r='.$rd.' '.$text);
} else if  ($soption->voption === 'clabels' and $soption->clabel!='') {
    $text = jText::_($elem);
}

MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

gap

Hello,

VM 3.0.18 (with J 3.6.4) -> the code of customfields.php has changed. How to change now the code in order that the dropdown label translation overrides work?

thanks
gap


Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

gap

Hello Milbo,

Thanks for your reply. I have VM 3.0.18 and it doesn't work for me. To be more precise, the structure is the next:

MULTIPACK PRODUCT (mother)
2 children as multi variants, named with "custom labels":
- Multivariant child1: "single color"
- Multivariant child2: "different colors"

These custom labels cannot be replaced by language override constants because you will see the constant name in the frontpage instead of the translation.

Multivariant is used because both children have their on attributes to choose. These are simple "string" type custom fields and language overrides work fine here!

Thus the problem exists with the multi variant custom labels only.

Have you got any hint how to solve that?

thanks
gap

Milbo

#5
Maybe I added it after the release of vm3.0.18.0

atm it looks like this in customfield.php (sublayouts) line 176


if($soption->clabel!='' and in_array($soption->voption,VirtueMartModelCustomfields::$dimensions) ){
$rd = $soption->clabel;
if(is_numeric($rd) and is_numeric($elem)){
$text = number_format(round((float)$elem,(int)$rd),$rd);
}
//vmdebug('($dropdowns[$k] in DIMENSION value = '.$elem.' r='.$rd.' '.$text);
} else if  ($soption->voption === 'clabels' and $soption->clabel!='') {
$text = vmText::_($elem);
}


You can also try the new version, is stable http://dev.virtuemart.net/attachments/download/1042/com_virtuemart.3.0.18.9_9423_extract_first.zip
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

gap

Hello Milbo,

Thanks for your reply. This code is indeed already in V.3.0.18 file. I tried now an update to 3.0.18.9 but didn't help too. Custom labels won't be translated, I can still see only my variant name in the dropbox.

Bug note: After update to V.3.0.18.9 I lost the product_horizon category view. It was choosen in the settings but the default view is loaded in the frontpage. I could only make a template sublayout override of products.php with the content of products_horizon.php in order to fix this.

jenkinhill

products_horizon setting is now in the extended Joomla menu item configuration, and can be selected separately for main and subordinate categories.  The selector under templates config needs removing.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Milbo

yepp. the updater just sets anywhere the layout, which is set in the vm config. This need to be enhanced.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

geniushost

#9
All you have to do is add vmText in the file view.html.php located in /components/com_virtuemart/views/category at line 616:

Change this:
if(!isset($valueOptions[$v->customfield_value])) {
$valueOptions[$v->customfield_value] = $v->customfield_value;
}


to this:
if(!isset($valueOptions[$v->customfield_value])) {
$valueOptions[$v->customfield_value] = vmText::_($v->customfield_value);
}


and your dropdown list in the search will be translated too.

This has to be already coded by default, so the "bug" is fixed and the problem is SOLVED.

Tanker

for some reason is not working on my end...
I have VM 3.6...
I'm using multivariant
I have declared the constants PR_VM_MEATS_YI
pr English and Spanish, then I use the custom fields then multivariant but instead of a translation what I got is the same variant as label and not the translation...