0

When programming a component for an API, the config contains the following language file definitions:

<api>
    <files folder="api">
        <folder>src</folder>
    </files>
    <languages folder="api">
        <language tag="en-GB">language/en-GB/com_mycomponent.ini</language>
        <language tag="en-GB">language/en-GB/com_mycomponent.sys.ini</language>
    </languages>
</api>

The component installs without errors, but the language files in the folder /api/language/en-GB/* of the component aren't copied to the folder /api/language/en-GB/ as described here https://www.dionysopoulos.me/book/com-lang.html.

When I copy the language files manually, they are interpreted correctly. Languages other than en-GB do not seem to work.

What am I missing?

2

1 Answer 1

1

If you want to keep the language files with the API rather than loading the language files into the shared \language directories you can use the simpler version of the elements in the manifest file.

Place your language files in your api\com_mycomponent\language the source folder and include the file in the com_mycomponent.zip.

In your mycomponent.xml you need to include the language folder in the <api> element to instruct it to be copied from the com_mycomponent.zip to the ..\api\com_mycomponent\language directory of the Joomla instance.

<api>
    <files folder="api">
        <folder>src</folder>
        <folder>language</folder>
    </files>
</api>

If you would like to place the language files in the shared language directory, \api\language, then the folder attribute of your language element needs to the reflect the location of the language folder inside the com_mycomponent.zip, where the language files are to be copied from.

<api>
...
    <languages folder="\location\in\zip">
        <language tag="en-GB">language/en-GB/com_mycomponent.ini</language>
        <language tag="en-GB">language/en-GB/com_mycomponent.sys.ini</language>
    </languages>
</api>

If you use the second approach then you don't need the <folder>language</folder> in the <files> element

2
  • Thanks Irata. For the 2nd approach it should say "If you would like to place the language files in the shared language directory, \api\language ... " and the <languages> folder should remain under the <api> element within the config file?
    – cappu
    Sep 27, 2023 at 8:52
  • 1
    I have updated the answer to correct folder name and made the location of the language element clearer as per your question.
    – Irata
    Sep 27, 2023 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.