News:

Support the VirtueMart project and become a member

Main Menu

Can't translate custom fields values

Started by razor7, October 10, 2012, 17:53:25 PM

Previous topic - Next topic

razor7

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

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

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

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

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

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

Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

saraee

Thank you but this part is for form field. My problem is with custom field value translation.

jjk

Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

saraee

Thanks again. I have read this post many times . It's about translating the custom field name and not custom field value.


saraee

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.