Author Topic: PHP Fatal error: Call to a member function _() on a non-object  (Read 8029 times)

Stefanos

  • Jr. Member
  • **
  • Posts: 93
PHP Fatal error: Call to a member function _() on a non-object
« on: January 15, 2010, 16:18:47 pm »
Hi all, please some help

I want to change the "Change Currency" text of the mod_virtuemart_currencies.php using Joom!fish. Just cause I didn't find it in Joom!fish, I edited the mod_virtuemart_currencies.php file near the last line from this:

Code: [Select]
<input class="button" type="submit" name="submit" value="<?php echo 'Change Currency' ?>" />
to this:

Code: [Select]
<input class="button" type="submit" name="submit" value="<?php echo $VM_LANG->_('CURRENCY_CHANGE_MODULE_TEXT'?>" />

I also added the following line to the /administrator/components/com_virtuemart/languages/common/english.php

Code: [Select]
'CURRENCY_CHANGE_MODULE_TEXT' => 'Change',
.. and of course it's translation to my language file. (I didn't forget the "," at the end of previous line)

All I get is this error:

PHP Fatal error:  Call to a member function _() on a non-object in /home/username/public_html/sitename/modules/mod_virtuemart_currencies/mod_virtuemart_currencies.php on line 101

I must do something wrong there some tip or help please ?

I use the following:

Joomla! 1.5.15
Virtuemart 1.1.4 // Language_Pack_for_VirtueMart_1.1.4 // com_martlanguages_1.1c
Joom!Fish 2.0.4 // virtuemart.1.1_joomfish.2.0_contentelementfiles
JoomSEF 3.5.3 // ext_joomsef3_virtuemart

I tried disabling sef also cleared cache but nothing...

thanks a lot guys for any help

Stefanos

  • Jr. Member
  • **
  • Posts: 93
Re: PHP Fatal error: Call to a member function _() on a non-object
« Reply #1 on: January 15, 2010, 19:54:54 pm »
Ok I found it, I was making a mistake using $VM_LANG

so for those that need something similar, create or edit /language/en-GB/en-GB.mod_virtuemart_currencies.ini

add in this code:
Code: [Select]
CURRENCY_CHANGE_MODULE_TEXT=Change
>> repeat the same in a file for the language you want to change, example, if you use English / Greek, then you need el-GR.mod_virtuemart_currencies.ini file in the directory /language/el-GR/

add this code inside it:
Code: [Select]
CURRENCY_CHANGE_MODULE_TEXT=Αλλαγή
Rememeber to save it in UTF-8 Format (use Notepad if you are on windows)

then just open your /modules/mod_virtuemart_currencies/mod_virtuemart_currencies.php (always backup the original first), find the following code at the end of the file:
Code: [Select]
<input class="button" type="submit" name="submit" value="<?php echo 'Change Currency' ?>" />
replace it with this:
Code: [Select]
<input class="button" type="submit" name="submit" value="<?php echo JText::_'CURRENCY_CHANGE_MODULE_TEXT'); ?>" />
cheers!


adan

  • Beginner
  • *
  • Posts: 41
Re: PHP Fatal error: Call to a member function _() on a non-object
« Reply #2 on: February 01, 2010, 14:33:51 pm »
Thanks you very much. This helped me a lot. The changes you described work fine for the button translation.

One question : did you manage to translate the module using joomfish? When I translate it and I click on save nothing happens.

Thnaks again and hope you can help with the module issue translation.

Regards

Stefanos

  • Jr. Member
  • **
  • Posts: 93
Re: PHP Fatal error: Call to a member function _() on a non-object
« Reply #3 on: February 01, 2010, 14:53:12 pm »
Hi adan, glad this helped you,

so you want to translate the module so you can have it's translation on the backend ? or you want to translate the currencies in another language ?

do you use the contentelements of virtuemart for joomfish ? and which ones ?
check this page, these are the right contentelements so far:
http://www.gjcwebdesign.com/joomla-15-virtuemart-11-joomfish-20.html

by the way, I uninstalled com_martlanguages_1.1c it was useless at all and also needed legacy. so now I am back to Native mode without it and everything is perfect.

let me know if I helped again
cheers

adan

  • Beginner
  • *
  • Posts: 41
Re: PHP Fatal error: Call to a member function _() on a non-object
« Reply #4 on: February 01, 2010, 15:27:33 pm »
Yes I am using the contentelements of virtuemart for joomfish, the one of the link you put above.

I am   building english/french site. I've already translated everything to french execpt the changecurrecny component. With your help above I managed to translate the text on the button. I need now to translate the text defined in the module (the list of currencies for example in the popup menu).

I go to joomfish/translation. I choose the content elements "Modules", I click on the module Currency Selector. I do the translation in the opened form. But impossible to save the translation.

Did you manage to do the translation of this module.

Thanks

Stefanos

  • Jr. Member
  • **
  • Posts: 93
Re: PHP Fatal error: Call to a member function _() on a non-object
« Reply #5 on: February 01, 2010, 15:42:53 pm »
Hi,

If you need to translate the currencies for example "US Dollar" to "Dollar des √Čtats-Unis" (I just found this translation on google sorry if it's wrong), then in joomfish you should choose to translate the --> "VirtueMart Currency". This is how it appears in the list of joomfish "Content elements:" dropdown. If you choose that, you will see the huge list of all currencies existin in VirtuemMart. I have translated the ones I use in my shop without a problem, yes.

Now if you go where you went, > modules > module currency Selector, you will only translate the module itself. If you don't use it's title to the Front End, then you don't need to translate it unless you want the French version on the backend. Personally I haven't translated this one, no, so I don't know what happens in this case really.

let me know if that helps

Stefanos

  • Jr. Member
  • **
  • Posts: 93
Re: PHP Fatal error: Call to a member function _() on a non-object
« Reply #6 on: February 01, 2010, 15:50:35 pm »
if you can't see the VirtueMart Currency then check if you have this:
/administrator/components/com_joomfish/contentelements/vm_currency.xml

adan

  • Beginner
  • *
  • Posts: 41
Re: PHP Fatal error: Call to a member function _() on a non-object
« Reply #7 on: February 01, 2010, 16:10:04 pm »
OK I can do the translation using VirtueMart Currency, that's great.
Remains the module title, for this I am forced to do it by choosing the module Currency Selector. The translation of this one does not work (cannot save).

Other persons have met this problem already but I could not find a solution. I beleive that everybody has removed the title as I am going to do to avoid this problem.

Thanks very much.

Stefanos

  • Jr. Member
  • **
  • Posts: 93
Re: PHP Fatal error: Call to a member function _() on a non-object
« Reply #8 on: February 01, 2010, 16:18:45 pm »
Hi again,

you made me curious and went to translate it's title..
well I cannot even save the change, joomla gets stuck totally and I have to type in the address of my site again on firefox :) that's nice :(

if you want to use a title for this module you can do it other ways, but depends on the area you use, example you can use an article or a custom html to go with it I guess,.. but needs much css tricks to stick it right in place :)

glad I helped
chees

adan

  • Beginner
  • *
  • Posts: 41
Re: PHP Fatal error: Call to a member function _() on a non-object
« Reply #9 on: February 01, 2010, 17:59:11 pm »
CSS is my weak point.
I found a fix in joomfich forum that suggests to change the file mod_virtuemart_currencies.xml
I tried it and it works even if I prefer to avoid the hacks.
The hack is just to remove this piece of code in mod_virtuemart_currencies.xml :
<param name="cache" type="radio" default="0"
         label="Enable Cache"
         description="Select whether to cache the content of this module">
         <option value="0"><![CDATA[
   <script src="../components/com_virtuemart/js/mootools/mootools-release-1.11.js"type="text/javascript"></script>
   <script type="text/javascript">
   function getCList() {
      for (var i = 0; i < document.adminForm.elements.length; i++) {
         if( document.adminForm.elements.name == 'params[product_currency]' ) {
            var listField = document.adminForm.elements;
         }
      }
      return listField;
   }
window.addEvent('domready', function() {
      var listField = getCList();
      
      new Ajax('index3.php', {
         method: 'get',
         data: { option: 'com_virtuemart', page:'product.ajax_tools', task:'getcurrencylist', no_html:1,product_currency: listField.value, selectSize: '10', multiple:'1', elementName: 'params%5Bproduct_currency%5D' },
         update: getCList().parentNode
      }).request();
      var jpane = $E("div.jpane-slider");
      if( jpane ) { jpane.setStyle("height", "auto" );jpane.setStyle("overflow", "auto" ); }
   }
);
function makeCurrencyList( o ) {
      var listField = getCList();
      //listField.parentNode.innerHTML = o.responseText;
   }
   document.adminForm.onsubmit = function() {
      var listField = getCList();
      var currencies = '';
      for (var i = 0; i < listField.options.length; i++) {
         if( listField.options.selected ) {
            currencies += listField.options.value + ',';
         }
      }
      listField.parentNode.innerHTML = '<input type="text" name="params[product_currency]" value="' + currencies + '" />';
   }
   </script>
   ]]>No
         </option>
         <option value="1">Yes</option>
      </param>


Regards

Stefanos

  • Jr. Member
  • **
  • Posts: 93
Re: PHP Fatal error: Call to a member function _() on a non-object
« Reply #10 on: February 01, 2010, 18:09:28 pm »
great one.. I avoid hacks too but always upload the original file to server too named filename_(original).php so I know I did something to it when updates come up.

I will have in mind when I need to translate the title.
it might get corrected in next releases of virtuemart though (hope)

cheers !