Author Topic: Emails are not in Customers Language  (Read 6193 times)

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2433
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Emails are not in Customers Language
« Reply #15 on: November 20, 2016, 02:05:28 am »
I think that VM does not add the lang tag in the link to generate the order, so it use the default one.
When i need more then one language in Joomla, i use instance foreach lang to be sure to get the right one.
eg in a  class:
Code: [Select]
$jText = array();
if (JLanguage::exists($code)) {
                $this->jText[$code] = JLanguage::getInstance($code);
                $this->jText[$code]->load('com_virtuemart');
                $this->jText[$code]->load('com_virtuemart_order');
            }
and after
$this->jText[$lang]->_('MY_KE_TO_TRANSLATEY);

But i think that Vm use only one instance for all.

eg :
Code: [Select]
if($noVendorMail and !empty($view->orderDetails) and !empty($view->orderDetails['details']['BT']->order_language)) {
VmConfig::loadJLang('com_virtuemart',true,$view->orderDetails['details']['BT']->order_language);
VmConfig::loadJLang('com_virtuemart_shoppers',TRUE,$view->orderDetails['details']['BT']->order_language);
VmConfig::loadJLang('com_virtuemart_orders',TRUE,$view->orderDetails['details']['BT']->order_language);
} else {
VmConfig::loadJLang('com_virtuemart_shoppers',TRUE);
VmConfig::loadJLang('com_virtuemart_orders',TRUE);
}
// some line after
vmText::_( 'COM_VIRTUEMART_DEFAULT_MESSAGE_SUBJECT' );

So, if you send multiple mails, as in this case, language is set to last loaded(or first loaded) order_language, so you are never sure, this is the right language.
vmText sould use a parameter more : vmText::_( 'COM_VIRTUEMART_DEFAULT_MESSAGE_SUBJECT' ,false, ^$order_language);
But in this case only the existing language.ini file loaded are used.(no template overides or Joomla overides).

In all case, it's complicate  if you need to write document in multiple  language at same PHP call.

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 834
  • VirtueMart Version: VM3 on J3
Re: Emails are not in Customers Language
« Reply #16 on: November 20, 2016, 10:52:40 am »
Quote
also Invoice PDF Header/Footer = still the wrong language

Can't confirm this. I've Header and Footer in the correct order language if I go to Backend and klick "create invoice" with J3.0.18.4. You must delete the old PDF-Files before you generate a new one.


Quote
But in this case only the existing language.ini file loaded are used.(no template overides or Joomla overides).

But the current problem are the joomla overrides.

Quote
JLanguage::getInstance($code);

I've tried this before, does not work for the overrides.


Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2433
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Emails are not in Customers Language
« Reply #17 on: November 20, 2016, 19:20:16 pm »


Quote
JLanguage::getInstance($code);

I've tried this before, does not work for the overrides.

[/quote]
See JLanguage class in JROOT\libraries\joomla\language\language.php, override is always loaded in the instance(constructor), but if you call this with a administrator link, then this give you the administrator overides and not front end.
So if the called fie are in back-end you need to add your overide in the backend and not in front enn only, it's why i say, this is complicate, because many do the error to add front overide, but the link for orderstatut update is admin side.
Mostly, i add same overide in front and back-end when i know that this can be used in the 2 cases, and worked always.

Of course using languages instances, permit to be completly sure, 2 diferent languages are loading, so you be sure to have not such problems.

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 834
  • VirtueMart Version: VM3 on J3
Re: Emails are not in Customers Language
« Reply #18 on: November 21, 2016, 00:18:40 am »
Patrick please read the thread, the problems are not FE or BE overrides.

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2433
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Emails are not in Customers Language
« Reply #19 on: November 21, 2016, 00:32:09 am »
Joomla! 3.6.4
PHP-Version 5.6.26
VirtueMart 3.0.18


Hi there,

I have a multilingual shop. 5 languages.
BE language is German.

I recieve the Customer Confirmation in the chosen language from the FE. Thats OK!
When i confirm in the BE, the Email as also PDF are generated in the BE language (German), which is wrong, not in Customers language.

What i am doing wrong??

*Edit*
I updated to PHP 7
Multilanguage status: all green

Problem still the same :(


Is the first post.
I give you the technic i use to write multilingual PDF at same time, that always set the right language.
You said it not work because overide(or another user), but it work and i added the ref, it's all.

I think you know that in case of multiple mails call , you  not reload the languages(as i know) so this can load another language, because you don't use instance.
I don't know exactly the problem here, but i have same problem, with mixed language content in orders, subjects ... So i give you my solution that never give me any problems. Or the other one, adding the missing key and overides in back-end too.

But if you know why this not work always, then please fix it and we are all happy.
Regards,

Patrick

loui

  • Beginner
  • *
  • Posts: 14
  • Beating Bugs
  • VirtueMart Version: 3 on J3
Re: Emails are not in Customers Language
« Reply #20 on: November 21, 2016, 16:02:31 pm »
Quote
I've Header and Footer in the correct order language if I go to Backend and klick "create invoice" with J3.0.18.4.

I think you mean "force creation of invoice-Button" in the BE orders view - this works well

Not so if i look into the send Email H/F and Invoice H/F after BE order cofirmation.

*EDIT*
Header and Footer is fixed in the last release 3.0.18.4

But it seems not possible to change the used language of the overrides. One working solution for the invoice may be the following:  delete the overrides for each language and add these overrides as your own language files to your template.

https://www.yireo.com/tutorials/joomla/joomla-programming/721-load-a-custom-language-file-in-your-joomla-template
cant get this to work!

i tryed
Code: [Select]
$language =& JFactory::getLanguage();
$language->load('custom' , dirname(joomla/templates/my_template/language/de-DE/de-DE.custom.ini), $language->getTag(), true);
in the template index.php

and added a file for the overrides to the path. didn't work

also tryed:
Code: [Select]
$language =& JFactory::getLanguage();
$extension = 'com_virtuemart';
$base_dir = dirname(joomla/templates/my_template/language/de-DE/de-DE.custom.ini);
$language_tag = $language->getTag(); // loads the current language-tag
$language->load($extension, $base_dir, $language_tag, true);

single template ini didn't work
Quote
JOOMLA/language/en-GB/en-GB.tpl_my_template.ini

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2433
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Emails are not in Customers Language
« Reply #21 on: November 21, 2016, 18:45:36 pm »
$language->load('custom' , dirname(joomla/templates/my_template/language/de-DE/de-DE.custom.ini), $language->getTag(), true);
is bad
$language->load('tpl_my_template' , JPATH_SITE.'/templates/my_template/language', $language->getTag(), true);
perhaps better
But try to add your front overides in the administrator language folder and check if it work.
file is administrator/language/overrides/de-DE.override.ini
But if you add your overides in front language/overrides/de-DE.override.ini, this have chance to work to. But i think is that VM force to overides and it's why this remove the original overides.
Joomla doc here https://docs.joomla.org/Loading_extra_language_files and https://docs.joomla.org/Specification_of_language_files

loui

  • Beginner
  • *
  • Posts: 14
  • Beating Bugs
  • VirtueMart Version: 3 on J3
Re: Emails are not in Customers Language
« Reply #22 on: November 21, 2016, 20:49:01 pm »
thank you for your input
$language->load('custom' , dirname(joomla/templates/my_template/language/de-DE/de-DE.custom.ini), $language->getTag(), true);
is bad
$language->load('tpl_my_template' , JPATH_SITE.'/templates/my_template/language', $language->getTag(), true);
perhaps better
i tryed this but had no luck
Quote
But try to add your front overides in the administrator language folder and check if it work.
file is administrator/language/overrides/de-DE.override.ini
But if you add your overides in front language/overrides/de-DE.override.ini, this have chance to work to. But i think is that VM force to overides and it's why this remove the original overides.
Joomla doc here https://docs.joomla.org/Loading_extra_language_files and https://docs.joomla.org/Specification_of_language_files
FE overrides didn't work in admin side also BE didn't work in FE view.

i think we have here a pretty complex issue with the languages to be shown correctly in all cases like emails and emailPDFs.

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2433
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Emails are not in Customers Language
« Reply #23 on: November 21, 2016, 21:20:41 pm »
See message before http://forum.virtuemart.net/index.php?topic=135863.msg474630#msg474630
But are your language files not bad formated ? You can try to activate language debug in Joomla config, and display the order view, you get a report on the debug position, if keys are missing, or errors in language files.

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 834
  • VirtueMart Version: VM3 on J3
Re: Emails are not in Customers Language
« Reply #24 on: November 22, 2016, 10:03:52 am »
try

$language->load('custom' , JPATH_SITE.'/templates/my_template', $language->getTag(), true);

filename: de-DE.custom.ini

loui

  • Beginner
  • *
  • Posts: 14
  • Beating Bugs
  • VirtueMart Version: 3 on J3
Re: Emails are not in Customers Language
« Reply #25 on: November 22, 2016, 16:41:09 pm »
no errors in language files.

just a bit curious about this ...
Code: [Select]
**Nicht geladen** : JROOT/administrator/language/de-DE/de-DE.com_tcpdf.sys.ini
**Nicht geladen** : JROOT/administrator/language/en-GB/en-GB.com_tcpdf.sys.ini
**Nicht geladen** : JROOT/administrator/components/com_tcpdf/language/de-DE/de-DE.com_tcpdf.sys.ini
**Nicht geladen** : JROOT/administrator/components/com_tcpdf/language/en-GB/en-GB.com_tcpdf.sys.ini

Quote
$language->load('custom' , JPATH_SITE.'/templates/my_template', $language->getTag(), true);

filename: de-DE.custom.ini
didn't work

i am now on
VirtueMart 3.0.18.5 Blue Corvus 9386

*EDIT*

OK. I finaly got the index.php to load this file with:

Code: [Select]
$language =& JFactory::getLanguage();
 $language->load('tpl_my_template' , JPATH_SITE.'/templates/my_template', $language->getTag(), true);
 

ini is loaded
Code: [Select]
**Geladen** : JROOT/templates/my_template/language/de-DE/de-DE.tpl_my_template.ini
but its overwriten by other ini loaded after this like:
Quote
**Geladen** : JROOT/language/de-DE/de-DE.com_virtuemart.ini

may be i need to load it as last one ...

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2433
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Emails are not in Customers Language
« Reply #26 on: November 22, 2016, 21:55:19 pm »
It's what i said before. Because Virtuemart force sometime overide, any change are removed, it's why using the real Joomla language overrides, can perhaps work better:
see YOURSITE/administrator/index.php?option=com_languages&view=overrides and add here your overrides.

For :
**Nicht geladen** : JROOT/administrator/language/de-DE/de-DE.com_tcpdf.sys.ini
**Nicht geladen** : JROOT/administrator/language/en-GB/en-GB.com_tcpdf.sys.ini
**Nicht geladen** : JROOT/administrator/components/com_tcpdf/language/de-DE/de-DE.com_tcpdf.sys.ini
**Nicht geladen** : JROOT/administrator/components/com_tcpdf/language/en-GB/en-GB.com_tcpdf.sys.ini
This is because the files are not existing, but perhaps you have another problem ?

You need perhpas to remove com_tcpf from Joomla(best on using joomla manager.)
And extract from com_virtuemart.3.0.18_extract_first.zip package the new one and install it. should perhaps solve the problem.
(I don't understand why this is not a package, but a component, but this is another history.)

And yes, to be sure your own translations are used you need to load after and overide Vm language files too(or use com_languages overrides).

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9416
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Emails are not in Customers Language
« Reply #27 on: December 21, 2016, 22:20:12 pm »
I think that VM does not add the lang tag in the link to generate the order, so it use the default one.
When i need more then one language in Joomla, i use instance foreach lang to be sure to get the right one.
eg in a  class:
Code: [Select]
$jText = array();
if (JLanguage::exists($code)) {
                $this->jText[$code] = JLanguage::getInstance($code);
                $this->jText[$code]->load('com_virtuemart');
                $this->jText[$code]->load('com_virtuemart_order');
            }
and after
$this->jText[$lang]->_('MY_KE_TO_TRANSLATEY);


Thank you, check the code, I think I got it now. I mixed your ideas with mine and think it is solved now
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Aglaia

  • Beginner
  • *
  • Posts: 4
  • A beginner
Re: Emails are not in Customers Language
« Reply #28 on: February 09, 2017, 10:44:11 am »
Hi,

I am working with VM 3.0.18
Joomla! 3.6.5
php-Version     5.6.28

I have the same problem wth the e-mails.

Milbo – you said you have solved it. Can you please tell me how.
Thanks

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3188
  • using Piwik instead of Google Analytics
Re: Emails are not in Customers Language
« Reply #29 on: February 09, 2017, 12:01:29 pm »
Probably the fix was included in VM 3.0.18.5. But I would suggest to test and eventually update to VM 3.0.19.5.
http://dev.virtuemart.net/projects/virtuemart/files
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations