Author Topic: [SOLVED] Multi-language VAT rule is not translated in several places  (Read 2465 times)

acarvalho

  • Beginner
  • *
  • Posts: 13
  • A beginner
Re: Multi-language VAT rule is not translated in several places
« Reply #15 on: April 07, 2021, 11:44:38 am »
I know when I am not wanted, this is not sarkasm ...
This not a matter of not being wanted, I just want to stick to the topic and get this fixed.

What I would like is to understand if there is a way to translate this kind of elements. Either the constant is not the way to go, or there is another way to do it.

I could override it in the code (when VM reads it from the db I would make sure it would translate it), but that would be destroyed each time VM is updated.

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3483
  • VirtueMart Version: 3.8.9
Re: Multi-language VAT rule is not translated in several places
« Reply #16 on: April 07, 2021, 11:54:58 am »
"Could any of you try it by yourself? it doesn't even need to be multi-language. Just place a constant into the VAT rule and translate it in the language overrides and in your template language, then see what happens."

It is clear that the order edit and some other areas use the function  "getTaxNameWithValue"

This simply uses the stored calc_rule_name value so - you could adjust the function to translate if it finds the appropriate Language key

BUT - this does not take into consideration the tax country of the sale - which would need to be considered for Tax name disclosure.

I am also not certain that it considers the customer language for multi country sales - and the shipping country to which the tax charge is relevant


The first place to "adjust" for a translation is:
\components\com_virtuemart\helpers\shopfunctionsf.php


Code: [Select]
static public function getTaxNameWithValue($name, $value){
$value = rtrim(trim($value,'0'),'.');
// quorvia attempt to translate the name
$name = vmText::_($name);
if(empty($value)) return $name;
if(strpos($name,(string)$value)!==false){
$tax = $name;
} else {
$tax = $name.' '.$value.'%';
}
return $tax;
}


You should see that this function is used in a number of VM views - including invoices - carts - mail etc

Add the variable to your language files for FE and Admin

I have shown the translation working in BE and the value that is stored in the calc_rule_name
I have also shown you the customer email for an order update
Regards
A

Joomla 3.9.27
php 7.4

acarvalho

  • Beginner
  • *
  • Posts: 13
  • A beginner
Re: Multi-language VAT rule is not translated in several places
« Reply #17 on: April 07, 2021, 22:07:54 pm »
It is clear that the order edit and some other areas use the function  "getTaxNameWithValue"
(...)

Great find and update AH, thank you!

I'm going to test it, but from what you've shown, it works.

Any chance for this updated function to go into production in the future?

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3483
  • VirtueMart Version: 3.8.9
Re: Multi-language VAT rule is not translated in several places
« Reply #18 on: April 08, 2021, 09:45:54 am »
I have asked the devs to look at this option for future releases

I cannot confirm that it will definitely make the release
Regards
A

Joomla 3.9.27
php 7.4

acarvalho

  • Beginner
  • *
  • Posts: 13
  • A beginner
Re: Multi-language VAT rule is not translated in several places
« Reply #19 on: April 08, 2021, 10:28:28 am »
Thank you AH, I'm going to change this topic into [SOLVED]