VirtueMart Forum

VirtueMart 2 + 3 => Language/Translations => Topic started by: razor7 on October 10, 2012, 17:53:25 pm

Title: Can't translate custom fields values
Post by: razor7 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
Title: Re: Can't translate custom fields values
Post by: Sharack 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
Title: Re: Can't translate custom fields values
Post by: razor7 on October 10, 2012, 18:05:22 pm
Great! Thanks!
Title: Re: Can't translate custom fields values
Post by: hkyklai 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.
Title: Re: Can't translate custom fields values
Post by: jcourt 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
Title: Re: Can't translate custom fields values
Post by: saraee 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.
Title: Re: Can't translate custom fields values
Post by: jjk on September 26, 2017, 12:07:27 pm
@saraee
Did you try this already? https://docs.virtuemart.net/tutorials/multilingual-store/105-using-language-keys-in-form-fields.html
Title: Re: Can't translate custom fields values
Post by: saraee 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.
Title: Re: Can't translate custom fields values
Post by: jjk on September 26, 2017, 17:33:16 pm
http://forum.virtuemart.net/index.php?topic=96758.msg318220#msg318220
Title: Re: Can't translate custom fields values
Post by: saraee 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.
Title: Re: Can't translate custom fields values
Post by: K&K media production on September 26, 2017, 21:21:42 pm
I wrote a plugin for cf translation:

http://extensions.virtuemart.net/product/products/multilingual-translatable-custom-fields-detail
Title: Re: Can't translate custom fields values
Post by: saraee 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.