I've built a simple component that sends an email. Inside that component I have my translations strings stored in the ini. Here is some sample code of what I do:
$body = $this->getDetails["name"]." ".JText::_('COM_MYCOMPNOTIFY_MAIL_BODY1')."
".
JText::_('COM_MYCOMPNOTIFY_MAIL_BODY2')." ".$this->getDetails["name"]."
".
JText::_('COM_MYCOMPNOTIFY_MAIL_BODY3')." http://".$this->getDetails["domain"]."
";
This directory structure I have for my component has
language
en-GB
en-GB.com_mycompnotify.ini
pt-BR
pt-BR.com_mycompnotify.ini
My install xml file has this:
<files folder="site">
<filename>index.html</filename>
...
<folder>helpers</folder>
<folder>language</folder>
</files>
This works fine for the en-GB
language. But I can't get it to translate for pt-BR
. I think the issue is that I have an external php file that calls my component. So it wouldn't know to load pt-BR language file (I think).
So I tried to force it to load:
$lang = JFactory::getLanguage();
$lang->load('com_mycompnotify', JPATH_BASE, 'pt-BR'); //also tried JPATH_SITE
But no matter what I try I always get English.