dqsh30374 2013-12-12 13:54
浏览 5

too long

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.

  • 写回答

1条回答 默认 最新

  • doumeng2637 2013-12-12 15:00
    关注

    for specifying language files in component xml file you should add somthing like this :

    <languages folder="admin">
        <language tag="en-GB">language/en-GB/en-GB.com_NAME.ini</language>
        <language tag="en-GB">language/en-GB/en-GB.com_NAME.sys.ini</language>
        <language tag="pt-BR">language/pt-BR/pt-BR.com_NAME.ini</language>
        <language tag="pt-BR">language/pt-BR/pt-BR.com_NAME.sys.ini</language>
    </languages>
    

    if you are developing a component Not just for administrator side only, you can add site languages files like this :

    <languages folder="site">
        <language tag="en-GB">language/en-GB/en-GB.com_NAME.ini</language>
        <language tag="en-GB">language/en-GB/en-GB.com_NAME.sys.ini</language>
        <language tag="pt-BR">language/pt-BR/pt-BR.com_NAME.ini</language>
        <language tag="pt-BR">language/pt-BR/pt-BR.com_NAME.sys.ini</language>
    </languages>
    

    and for joomla to use the language files which aren't english you should change site's language to your native language.You can download translations for many languages from joomla's official site.

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用