0

I'm developing a template and I find it both interesting and confusing to how Joomla 4 loads language files.

First there is the templateDetails.xml notation:

Cassiopeia uses

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

In other extensions I see additions like en-GB., for instance

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

So the question is, does Joomla 4 load these language files from this location without having to copy them to site/language/en-GB folder on extension installation?

1 Answer 1

1

Cassiopeia and other core extensions have the files you're asking about installed as part of the Joomla package, so the references in the manifest files are to point to where a file even though it's installed as part of the package (eg the manifest file would be used to identify information when you Discover extensions).

Breaking down the en-GB file for the language pack:

<files>
    <filename plugin="languagecode">languagecode.php</filename>
    <filename>index.html</filename>
    <folder>language</folder>
</files>
<languages folder="language">
    <language tag="en-GB">en-GB/en-GB.tpl_templatename.ini</language>
    <language tag="en-GB">en-GB/en-GB.tpl_templatename.sys.ini</language>
</languages>
  • In the files section, you define the language folder to use. If you have multiple languages you can simply include the folder reference in the files section, and any language files in the installer package will unpack to that location.
  • In the languages section, the tag identifies the language to associate the files with, while the language folder tells Joomla which language subfolder to put the files into. So /language/en-GB/ as language was defined in the files section.

For a template I use, there's three languages it ships with, so it's manifest language section looks like this:

<languages folder="language">
    <!-- en-GB -->
    <language tag="en-GB">en-GB/en-GB.tpl_templatename.ini</language>
    <language tag="en-GB">en-GB/en-GB.tpl_templatename.sys.ini</language>
    <!-- es-ES -->
    <language tag="es-ES">es-ES/es-ES.tpl_templatename.ini</language>
    <language tag="es-ES">es-ES/es-ES.tpl_templatename.sys.ini</language>
    <!-- de-DE -->
    <language tag="de-DE">de-DE/de-DE.tpl_templatename.ini</language>
    <language tag="de-DE">de-DE/de-DE.tpl_templatename.sys.ini</language>
</languages>

A note on extensions

Since Joomla! 1.6 it is recommended that you place your extension's language files in your extension folder (This varies between extensions, particularly ones that have been around since Joomla 1.x). Joomla! searches for language files in a folder hierarchy: the extension language folder, the site language folder, then the language overrides folder. So if there's a file available further down the order, it will override the preceding language file.

By storing extension language files in the extension folder, you benefit by isolating and protecting your extension's language files. For example, an administrator removes a language from their Joomla! installation. Your extension's language files will not be removed. They will remain in place and will be available if the language is installed again.

See https://docs.joomla.org/Manifest_files for more information on Joomla's Manifest Files.

3
  • Thanks for the time to write an answer, however it won't help with my custom Editor Button, it will still show "PLG_EDITORSXTD_PLUGIN_NAME_EDITOR_BUTTON" unless I copy the files to administrator/language/en-GB/ folder. So I need to know: does Joomla 4 copy these files automatically on "regular install"? Does the "discover install" require manual copy of the language files to the above folder? Thanks
    – thednp
    Commented Aug 31, 2021 at 14:48
  • I solved the problem. It was in my code a hard coded language setting Factory::getLanguage()->load('plg_editors-xtd_myplugin', JPATH_ADMINISTRATOR, $lang->getTag(), true);. Basically was trying to get an editors-xtd plugin language file into a content plugin, but I figured another way around.
    – thednp
    Commented Sep 14, 2021 at 9:37
  • 1
    @thednp sorry to not reply sooner. If the files are listed in the installation manifest then it installs them both on regular install and discover install. Discover install is basically finding that there's an extension available and then runs the installation based on it's manifest.xml file. Commented Oct 13, 2021 at 23:53

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.