News:

Looking for documentation? Take a look on our wiki

Main Menu

Emails are not in Customers Language

Started by loui, October 27, 2016, 01:49:23 AM

Previous topic - Next topic

Studio 42

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:
$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 :
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

Quotealso 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.


QuoteBut 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.

QuoteJLanguage::getInstance($code);

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


Studio 42



QuoteJLanguage::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

Patrick please read the thread, the problems are not FE or BE overrides.

Studio 42

Quote from: loui on October 27, 2016, 01:49:23 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

#20
QuoteI'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*
Quote from: K&K media production on November 19, 2016, 17:03:14 PM
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
$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:
$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
QuoteJOOMLA/language/en-GB/en-GB.tpl_my_template.ini

Studio 42

$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

#22
thank you for your input
Quote from: Studio 42 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
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

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

try

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

filename: de-DE.custom.ini

loui

#25
no errors in language files.

just a bit curious about this ...
**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:

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


ini is loaded
**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

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

Quote from: Studio 42 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:
$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
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Aglaia

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

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