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

[SOLVED] Multi-language VAT rule is not translated in several places

Started by acarvalho, March 26, 2021, 19:36:28 PM

Previous topic - Next topic

acarvalho

Quote from: Jörgen on April 07, 2021, 08:17:22 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

"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



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 4.4.5
php 8.1

acarvalho

Quote from: AH on April 07, 2021, 11:54:58 AM
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

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 4.4.5
php 8.1

acarvalho

Thank you AH, I'm going to change this topic into [SOLVED]