VirtueMart Forum

VirtueMart 2 + 3 + 4 => Language/Translations => Topic started by: sebmolo on January 29, 2015, 14:31:47 PM

Title: How to translate availability message?
Post by: sebmolo on January 29, 2015, 14:31:47 PM
Hello,
I'd like to translate the availablity message set in the configuration.
For example to have :
"3 weeks max" in English
"3 semaines maximum" in French.

I tried to do the same as for custom fields and insert strings and to work with the language override files but I couldn't get it to work.
Any help?
Title: Re: How to translate availability message?
Post by: jjk on January 29, 2015, 22:48:06 PM
If you want to translate an availabilty text instead of using images, it should work similar to this: http://docs.virtuemart.net/tutorials/multilingual-store/105-using-language-keys-in-form-fields.html
Title: Re: How to translate availability message?
Post by: sebmolo on January 30, 2015, 11:06:31 AM
Hello and thanks for your answer.
Unfortunately your solution doesn't work for availability texts.
I already tried using language keys, the availability text doesn't seem to be recognised as such.
(that is what i meant with : I tried to do the same as for custom fields.)
Title: Re: How to translate availability message?
Post by: Miku on June 02, 2015, 17:47:07 PM
I'd like to refresh the topic looking for a solution in the related issue. Namely - availability images in a multilanguage site. Is that possible to set different ones per language? I have been looking for a solution but like other users:
http://forum.virtuemart.net/index.php?topic=121388.0
http://forum.virtuemart.net/index.php?topic=114378.0
I haven't found it... :( 

In VM3 I even can see an 'flag icon' next to the field 'availability image' which would suggest that there is such an option but there's no such though

Could anyone help?
Title: Re: How to translate availability message?
Post by: bortolani on January 03, 2016, 19:01:49 PM
In fact there is a way.
Put your image files in two different directories, one for each language.
Then modify the php file where you show the product details (usually it depends on the template you are using) and change the existing code for the availability display with something like this:


if (!empty($this->product->product_availability)) {
$stockhandle = VmConfig::get('stockhandle','none');
if($stockhandle=='none') {
$GifToPNG = substr($this->product->product_availability, 0, -3); }
else if($stockhandle=='risetime' and ($this->product->product_in_stock - $this->product->product_ordered)<1){
$GifToPNG = substr(VmConfig::get('rised_availability'), 0, -3); }
else if($stockhandle=='disableadd' and ($this->product->product_in_stock - $this->product->product_ordered)>=1){
$GifToPNG = substr($this->product->product_availability, 0, -3); }
if($stockhandle=='risetime' and ($this->product->product_in_stock - $this->product->product_ordered)>=1){
$GifToPNG = substr($this->product->product_availability, 0, -3); }
$imgUrl= JURI::root().'templates/'.$template.'/html/com_virtuemart/assets/images/availability/'. JTEXT::_('PUFFO_AVAILABILITY_DIR').$GifToPNG; ?>
<div class="availability">
<img src="<?php echo $imgUrl ?>png" class="FlexibleavailabilityIMG" alt="" /> </div>
<?php }
}


In practice use a language override variable to change the name of the directory where to look for the image.

Hope this helps,
Bruno