News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Custom fields translation in the backend

Started by Nick Hatzinikolaou, November 20, 2013, 14:37:48 PM

Previous topic - Next topic

Nick Hatzinikolaou

Hello,

I have set-up the custom fields translation by using overrides. but although the overrides works fine on the frontend, they do not in the backend, I still see COM_VIRTUEMART_Whatever in all the field values etc.
Am I doing something wrong, or those cannot be translated?

[the override ini file is present and filled in the admin languages folder...]

Thanks!

Alexander

OK i think i found a way to make it work on the backend.

go to administrator/components/com_virtuemart/views/product

open the file: view.json.php

at line 146 you will see the code:

<td><span class="hasTip" title="'.JText::_($field->custom_tip).'">'.$field->custom_title.'</td>

change it to

<td><span class="hasTip" title="'.JText::_($field->custom_tip).'">'.JText::_($field->custom_title).'</td>

and the custom field titles will work.

I am on Virtuemart 2.0.24b



Nick Hatzinikolaou

#2
Thank you for the reply! :)

Unfortunately I'm still running 2.0.24 since my template brakes with the latest version...
Sounds like a good hack.

Although the titles are beign translates once you save the product, it's the values that stay in the "raw" form...
https://dl.dropboxusercontent.com/u/5072151/values.jpg

Alexander

ok i know what you are talking about now,

what you need for that is a hack in the another php file.

file administrator/components/com_virtuemart/models/

open file customfields.php and find the function: public function displayProductCustomfieldFE

change the code that says:

$value = $customfield->custom_value;

to

$value = Jtext::_($customfield->custom_value);


I Hope it works for you,

GOOD LUCK

Nick Hatzinikolaou

Thanks! But it doesn't seem to work.

I'm using language overrrides for the translation, maybe that's the reason...

jjk

Should work without a hack. If you can supply a screenshot of your problem, somebody might have the time to test it.
Translating custom field values for the backend should be similar to the procedure in the frontend, which is described here: http://forum.virtuemart.net/index.php?topic=96758.0
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Alexander

Hello again Nick,

Hmmmm it is strange, because i am using overides too.

I will check it out again and will reply soon.

Alexander

OK Nick I found out what the problem was that didnt work for you.

I forgot to give you one more file you need to change.

So I will start it all from the beginning here so just in case you or anyone else gets lost along the way.

First step,

We create the extra fields and we give them titles for example COM_VIRTUEMART_CHAR_TYPE

In the language overrides section we create new entries in the desired languages ( my example is for Greek and English )

COM_VIRTUEMART_CHAR_TYPE="Type" for english and
COM_VIRTUEMART_CHAR_TYPE="Τύπος" for greek.

My Values for this extra field in the overrides is:

For English:
ΤΣΕΠΗΣ="Pocket"
ΠΡΟ-ΙΔΙΟΚΤΗΤΟ="Pre-Owned"
ΚΑΙΝΟΥΡΓΙΟ="New"

For Greek:
ΤΣΕΠΗΣ="Τσέπης"
ΠΡΟ-ΙΔΙΟΚΤΗΤΟ="Προ-Ιδιόκτητο"
ΚΑΙΝΟΥΡΓΙΟ="Καινούργιο"


Now lets move on to the next step where i have changed the coding to some files, BUT REMEMBER keep a copy of the original files just in case:

HACKS FOR CUSTOM FIELDS TO WORK WITH MULTILANGUAGE and OVERIDES.
================================================================

Hack 01

file administrator/components/com_virtuemart/views/product/view.json.php
------------------------------------------------------------------------
goto line 146 and change

<td><span class="hasTip" title="'.JText::_($field->custom_tip).'">'.$field->custom_title.'</td>

to

<td><span class="hasTip" title="'.JText::_($field->custom_tip).'">'.JText::_($field->custom_title).'</td>

Hack 02

file administrator/components/com_virtuemart/models/customfields.php
--------------------------------------------------------------------

find the function: public function displayProductCustomfieldFE

change the code that says:

$value = $customfield->custom_value;

to

$value = Jtext::_($customfield->custom_value);


HACK 03

Open File administrator/components/com_virtuemart/views/custom/tmpl/default.php
-------------------------------------------------------------------------------
and on line 101 it has

<td><?php echo JHTML::_('link', JRoute::_($link, FALSE), $custom->custom_title, array('title' => JText::_('COM_VIRTUEMART_EDIT').' '.$custom->custom_title)); ?></td>

change it to

<td><?php echo JHTML::_('link', JRoute::_($link, FALSE), JText::_($custom->custom_title), array('title' => JText::_('COM_VIRTUEMART_EDIT').' '.$custom->custom_title)); ?></td>


GOOD LUCK !!

Alexandros








Nick Hatzinikolaou

#8
Thanks for all for the replies!

Alexander, I don't have the exact same code in the json.php I have [running 2.0.24]

$html[] = '<tr class="removable">
<td>'.$field->custom_title.'</td>
<td>'.$field->custom_tip.'</td>
<td>'.$display.'</td>


So I added it to the first <td>

*Made the other changes too

But still no luck :p

I'm attaching caps from the various stages, in case I'm doing something boneheaded :p

[attachment cleanup by admin]

Alexander

OK Nick, this is what i am going to do,

I will roll back my Virtuemart to Version 2.0.24 and see about it.

In the meanwhile, i see that u are from Greece ? if so, maybe you can send me a pm or i send u a pm and we can talk about it on the phone ?

Alexander

Hello again Nick,

I rolled back my Virtuemart installation to 2.0.24 and did the corrections i described and its work for me.

I will leave you an pm and maybe you can give me a call so that i could guide you step by step.

Regards

Alexandros

Alexander

Look At These


[attachment cleanup by admin]

Alexander

and look at the overrides

[attachment cleanup by admin]

Nick Hatzinikolaou

Yeah it looks right :)

Do you also see the translations (the actual translations - not the values - of-course you used easy t read names in caps) while adding the filed to a product?

Like so?
http://forum.virtuemart.net/index.php?action=dlattach;topic=120401.0;attach=57262;image

Alexander

since my customer is Greek, either he logs in the admin with Greek or English language, the values will be displayed in Greek. The front of the e-shop though will show the values correctly in the desired language of the visitor.



[attachment cleanup by admin]