Author Topic: Can't translate custom fields values  (Read 3480 times)

razor7

  • Jr. Member
  • **
  • Posts: 314
    • MGSCreativa - Professional VM!
Can't translate custom fields values
« on: October 10, 2012, 17:53:25 pm »
Hi, I have created a custom field with title COM_VIRTUEMART_PRODUCT_STEMS and created two overrides, one for english and one for spanish, and the title gets translated just OK.

i have added two Keys for custom field values translation but it doesn't works, the fields allways get the KEY and don't get translated.

The key used in custom fields value is COM_VIRTUEMART_PRODUCT_11_STEMS and COM_VIRTUEMART_PRODUCT_19_STEMS that should get trasnlaetd to 11 stems and 19 stems.

Please advise

J! 2.5.7
VM 2.0.10
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

Sharack

  • Beginner
  • *
  • Posts: 8
Re: Can't translate custom fields values
« Reply #1 on: October 10, 2012, 18:00:20 pm »
Hi, just try this :) find here... 

http://forum.virtuemart.net/index.php?topic=100784.15



SOLVED

Change in: /administrator/components/com_virtuemart/models/customfields.php

Line 870
OLD:
$productCustom->text = $productCustom->custom_value . ' ' . $price;

NEW:
$productCustom->text =  JText::_ ($productCustom->custom_value) . ' ' . $price;

In your product give as a value of the custom field by example: COM_VIRTUEMART_COLOR_BLACK
In the language overrides you give the translations of COM_VIRTUEMART_COLOR_BLACK

Of course, nicer is it that you can translate this fields in the same way as you can translate the productname/product description in another language.


But it doesnt work for Customfields with textarea or editor... someone else got a solution for this?

Greetings,

Sharack

razor7

  • Jr. Member
  • **
  • Posts: 314
    • MGSCreativa - Professional VM!
Re: Can't translate custom fields values
« Reply #2 on: October 10, 2012, 18:05:22 pm »
Great! Thanks!
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

hkyklai

  • Beginner
  • *
  • Posts: 12
Re: Can't translate custom fields values
« Reply #3 on: November 09, 2012, 04:37:25 am »
Hi Sharack,

Thanks for your information helps a lot.

However, I found that the custom field is not translated in the notification mail which is sent out when the order status is updated (i.e. changed from "pending" to "confirmed"), although it is translated in the first notification mail when the customer place the order. Not understand why.

Should the customfields.php file or other php file be amended in order to have the custom field translated in the e-mail for the order status update?

I am using Joomla 2.5.7 and VM 2.0.12f.

Many thanks in advance.

jcourt

  • Beginner
  • *
  • Posts: 2
Re: Can't translate custom fields values
« Reply #4 on: January 28, 2013, 19:09:48 pm »
Hello,
      I have implemented this solution and it works fine on Firefox but it is vervy very slow on Internet Explorer 9 (15 second to show up).
The instruction was: Replace Line 870
OLD:
$productCustom->text = $productCustom->custom_value . ' ' . $price;

NEW:
$productCustom->text =  JText::_ ($productCustom->custom_value) . ' ' . $price;

I notice in my code I have to other location with the command that need to be replaced. Can you tell me if I need to replace those other locations?
Here beneath the part of file customfields.php with the 2 extra location with the command that is replaced on
=======================================  Code ======================================================
if ($group->field_type == 'E') {
                  $group->display = '';

                  foreach ($group->options as $k=> $productCustom) {
                     $price = self::_getCustomPrice($productCustom->custom_price, $currency, $calculator);
                     $productCustom->text = $productCustom->custom_value . ' ' . $price;
                     $productCustom->virtuemart_customfield_id = $k;
                     if (!class_exists ('vmCustomPlugin')) {
                        require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
                     }

                     //legacy, it will be removed 2.2
                     $productCustom->value = $productCustom->virtuemart_customfield_id;
                     JPluginHelper::importPlugin ('vmcustom');
                     $dispatcher = JDispatcher::getInstance ();
                     $fieldsToShow = $dispatcher->trigger ('plgVmOnDisplayProductVariantFE', array($productCustom, &$row, &$group));

                  //   $group->display .= '<input type="hidden" value="' . $k . '" name="customPrice[' . $row . '][' . $group->virtuemart_custom_id . ']" /> ';
                     $group->display .= '<input type="hidden" value="' . $productCustom->virtuemart_customfield_id . '" name="customPrice[' . $row . '][' . $productCustom->virtuemart_custom_id . ']" /> ';
                     if (!empty($currency->_priceConfig['variantModification'][0]) and $price !== '') {
                        $group->display .= '<div class="price-plugin">' . JText::_ ('COM_VIRTUEMART_CART_PRICE') . '<span class="price-plugin">' . $price . '</span></div>';
                     }
                     $row++;
                  }
                  $row--;
               }
               else {
                  if ($group->field_type == 'U') {
                     foreach ($group->options as $productCustom) {
                        $price = self::_getCustomPrice($productCustom->custom_price, $currency, $calculator);
                        $productCustom->text = $productCustom->custom_value . ' ' . $price;

                        $group->display .= '<input type="text" value="' . JText::_ ($productCustom->custom_value) . '" name="customPrice[' . $row . '][' . $group->virtuemart_custom_id . '][' . $productCustom->value . ']" /> ';
                        if (!empty($currency->_priceConfig['variantModification'][0]) and $price !== '') {
                           $group->display .= '<div class="price-plugin">' . JText::_ ('COM_VIRTUEMART_CART_PRICE') . '<span class="price-plugin">' . $price . '</span></div>';
                        }
                     }
                  }
============================================== End small part of code ==========================================================

I am using VM 2.0.18. Please tell me if I need to replace the other code?
That can be the cause why IE 9 is so slow when showing the customfields?
Thanks a lot for you time and answear.

My site is www.adonaiboeken.nl

Kind regards.
Julio de la Court

saraee

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: Can't translate custom fields values
« Reply #5 on: September 26, 2017, 08:53:55 am »
Thank you for this post. I use joomla 3 and virtuemart 3.2.2 and I could translate custom field name with help of forum post but I couldn't translate the custom field value.
In my  /administrator/components/com_virtuemart/models/customfields.php I didn't find below line:
$productCustom->text = $productCustom->custom_value . ' ' . $price;

Can any one help me? which kind of custom field I should select? string?
I know right now there is TRANSLATABLE CUSTOM FIELDS plugin and also Custom Fields For All  but I need to translate it myself.

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3187
  • using Piwik instead of Google Analytics
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

saraee

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: Can't translate custom fields values
« Reply #7 on: September 26, 2017, 13:10:30 pm »
Thank you but this part is for form field. My problem is with custom field value translation.

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3187
  • using Piwik instead of Google Analytics
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

saraee

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: Can't translate custom fields values
« Reply #9 on: September 26, 2017, 20:12:47 pm »
Thanks again. I have read this post many times . It's about translating the custom field name and not custom field value.

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 834
  • VirtueMart Version: VM3 on J3
Re: Can't translate custom fields values
« Reply #10 on: September 26, 2017, 21:21:42 pm »

saraee

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: Can't translate custom fields values
« Reply #11 on: October 07, 2017, 13:54:33 pm »
Finally I could solve the problem  ;D
For translating the custom field name this post helped me:
http://forum.virtuemart.net/index.php?topic=96758.msg318220#msg318220
but for translating the value:
first select a custom field type string
Then change in file components/com_virtuemart/sublayouts/customfield.php line 421
   case 'S':
         change to
    case 'S':
            $customfield->custom_value= JText::_($customfield->custom_value;
and same as custom field names, use joomla override to translate it .
Wish it can help others.