1
votes

My question is basically the same as in Joomla 3 Article Modal form field in custom module. How ever the solution proposed in the answer of that question produces a problem with the translation in my module.

The "Select article" field is correctly included in the params section of my module backend, but the strings are not translate:

enter image description here

I have used the following code to include the form field:

<fields name="params" addfieldpath="administrator/components/com_content/models/fields">
    <fieldset name="..." label="..." >
        <field name="id" type="modal_article"
               label="Select Article" description="Article Id" />
        ...
    </fieldset>
</fields>

The only visible difference I see is that I use name="params" instead of name="basic". But if I use basic then the whole form field section disappears.

I have already tried different ways to import the language file but none has work so far.

Update: I had originally use the language override of Joomla to resolve this issue, now I needed to make the module portable and so I added the translations directly into the module:

I have created the following folder structure inside my module:

|-- ...
|-- tmpl/
|-- language/
   \-- en-GB/
      \--en-GB.mod_mymodule.ini

Then I added the following code to my mod_mymodule.xml:

<languages folder="language">
    <language tag="en-GB">en-GB/en-GB.mod_mymodule.ini</language>
</languages>

And in the ini file I have defined the following variables:

COM_CONTENT_SELECT_AN_ARTICLE="Select an article"
COM_CONTENT_CHANGE_ARTICLE_BUTTON="Select / Change"

This works but it seems that the file name must follow the convention: <lang>.<module name>.ini, where <lang> is for example en-GB and <module_name> is for example mod_mymodule. If the name is slightly different it does not seem to work.

1
Have you tried joomla language overrides? docs.joomla.org/J2.5:Language_Overrides_in_Joomlamelc
Thank you. That solved the problem. If you write your suggestion into an answer I will mark it as correct answer.lanoxx
great, i'm glad the issue was resolved. Have you also created language files for your module? If you do you will probably also manage to resolve it there and skip the override. I'll put up an answer to assist other visitors as well. Thanks.melc
So far I have not localized my module. I would have expected that Joomla pulls the translations from the com_content component, as it already has a translation for those strings.lanoxx

1 Answers

1
votes

In order to translate a Joomla language constant i.e. COM_CONTENT_SELECT_AN_ARTICLE you can use Joomla language overrides http://docs.joomla.org/J2.5:Language_Overrides_in_Joomla . In addition the issue may also be resolved if language files for the specific module are created containing the language constant and a corresponding translation.