Advertisement

correct linking to language files

General questions regarding the use of languages in Joomla! 5.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
hekla
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Dec 20, 2011 10:05 pm

correct linking to language files

Post by hekla » Fri Oct 25, 2024 2:04 pm

When looking at J5 extensions and how they handle language file linking, I find different approaches:

In Akeeba Backup, for example, I find:

Code: Select all

<files folder="frontend">
	<folder>language</folder>
	<folder>src</folder>
</files>
<languages folder="frontend">
	<language tag="en-GB">language/en-GB/com_akeebabackup.ini</language>
</languages>
in Joomla 6alpha:

Code: Select all

<languages>
	<language tag="en-GB">language/en-GB/plg_finder_content.ini</language>
	<language tag="en-GB">language/en-GB/plg_finder_content.sys.ini</language>
</languages>
Regularlabs:

Code: Select all

<languages folder="language">
	<language tag="en-GB">en-GB/en-GB.pkg_regularlabs.sys.ini</language>
</languages>
My questions are:

1) What is the best practice for linking language files?
  • <folder>language</folder>
  • <language tag="en-GB">language/en-GB/plg_finder_content.ini</language>
  • or both ways above
2) How should the INI files be named - with or without the language code?
  • en-GB.pkg_extension.ini
  • pkg_extension.ini
I also need to consider language overrides to ensure they continue working.

Advertisement
User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 25287
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: correct linking to language files

Post by pe7er » Sat Oct 26, 2024 10:04 am

Installing extension with language files via the .xml manifest

<files folder="frontend">
<folder>language</folder>
<folder>src</folder>
</files>
will copy the complete folder with all languages to your extension folder.
If you install a language later in Joomla, and that language is in your extension's /languge/ folder, then it will be available immediately.
This is what I always do.

<languages folder="language">
<language tag="en-GB">language/en-GB/plg_finder_content.ini</language>
</languages>
will copy the language file to Joomla's /language/en-GB/ where it will reside within all Joomla's language files (which are lot!).
However, if you install another language later in Joomla, then you'll have to reinstall your extension to install its language file.
I don't use this method because I like to keep my language files with my own extension (which is easier to manage).

Naming the language files
In the past the language files would include the language code, like
en-GB.pkg_extension.ini

Since Joomla 4 (possibly earlier with a Joomla 3) you can leave out the language code like
pkg_extension.ini
because its in the folder already. This is what I use.

So I recommend to only use <folder>language</folder> (and not use the <languages> tag)
and language files without the language code prefix, like pkg_extension.ini
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

SharkyKZ
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3108
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: correct linking to language files

Post by SharkyKZ » Sat Oct 26, 2024 11:07 am

Joomla always looks for language files in global language directory first so using <languages> tag is faster. Using files without language prefix is only supported since 3.10 and is also prioritized on 4.0+.

hekla
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Dec 20, 2011 10:05 pm

Re: correct linking to language files

Post by hekla » Sat Oct 26, 2024 2:21 pm

Thank you, Peter for you detailed explanations and SharkyKZ for your addition.

What about the overrides?
Is there a difference depending on how I link the language files.

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 25287
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: correct linking to language files

Post by pe7er » Sat Oct 26, 2024 2:41 pm

hekla wrote: Sat Oct 26, 2024 2:21 pm Thank you, Peter for you detailed explanations and SharkyKZ for your addition.

What about the overrides?
Is there a difference depending on how I link the language files.
You're welcome!
No, there's no difference regarding loading the language files.
Those overrides are loaded first.
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

Advertisement

Post Reply

Return to “Language - Joomla! 5.x”