Author Topic: Translate Multi Variant custom labels  (Read 1823 times)

razor7

  • Jr. Member
  • **
  • Posts: 322
    • MGSCreativa - Professional VM!
Translate Multi Variant custom labels
« on: April 15, 2015, 14:15:26 pm »
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:
Code: [Select]
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:
Code: [Select]
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

  • Beginner
  • *
  • Posts: 18
Re: Translate Multi Variant custom labels
« Reply #1 on: December 10, 2016, 17:44:34 pm »
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

gap

  • Beginner
  • *
  • Posts: 18
Re: Translate Multi Variant custom labels
« Reply #2 on: December 17, 2016, 11:30:58 am »
Anyone?  :-\

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9649
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Translate Multi Variant custom labels
« Reply #3 on: January 05, 2017, 16:02:21 pm »
It should be already that way
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

gap

  • Beginner
  • *
  • Posts: 18
Re: Translate Multi Variant custom labels
« Reply #4 on: January 15, 2017, 17:13:44 pm »
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9649
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Translate Multi Variant custom labels
« Reply #5 on: January 16, 2017, 17:28:17 pm »
Maybe I added it after the release of vm3.0.18.0

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

Code: [Select]
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
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

gap

  • Beginner
  • *
  • Posts: 18
Re: Translate Multi Variant custom labels
« Reply #6 on: January 18, 2017, 11:57:34 am »
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

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26975
  • Always on vacation
    • Jenkin Hill Internet
Re: Translate Multi Variant custom labels
« Reply #7 on: January 18, 2017, 12:26:17 pm »
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

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM..3.4.0.9935 on Joomla 3.8.12 PHP 7.0.31

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9649
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Translate Multi Variant custom labels
« Reply #8 on: January 18, 2017, 15:50:13 pm »
yepp. the updater just sets anywhere the layout, which is set in the vm config. This need to be enhanced.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

geniushost

  • Beginner
  • *
  • Posts: 1
  • A beginner
Re: Translate Multi Variant custom labels (SOLVED)
« Reply #9 on: June 15, 2018, 08:16:43 am »
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:
Code: [Select]
if(!isset($valueOptions[$v->customfield_value])) {
$valueOptions[$v->customfield_value] = $v->customfield_value;
}

to this:
Code: [Select]
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.