Creating multilingual sites became a lot easier with the new core integration of supporting more languages. On top of that we have an option to change the language text right from inside Joomla Admin. There is no need to hack the language files or create our own we let Joomla handle it.
Opening the language override menu in Joomla admin
The menu is located under Extensions > Language Manager, under the tab Overrides. We come to an interface where we can filter, choose a language file for the admin or front-end, and a table of any current overrides that we have. Depending with what language we want to work, we select it from the drop down.
How do language overrides work
When you create some overrides, Joomla creates the ini files in the language > overrides folder. The file will be named as language.override.ini. It is very important that our changes are saved in a separate file, because we can update our Joomla installation without worrying about loosing our changes. Even better is overriding the default language strings or making them up ourselves.
Overriding the default language strings
Most of the time you will want to overwrite the default language strings. The quickest way is to click on the button New, which brings you to the bottom screen.
A language string consists from two parts, a constant and a value. If we know the names and values we can insert them into the field on the left. Even easier is to search for the value and then change it. The value is what you see on the front page. If changing the “Read more” text is desirable, insert it into the search field and select it from the list. After clicking it should populate the fields on the left.
Constants are meant for developers. From the above example the constant name is COM_CONTENT_READ_MORE, it is the string that is used in the php files responsible for the component or templates. They come in handy when you want to create custom strings to use in your template.
Using custom language strings in Joomla templates
Building a component or theme requires some custom design and functionality, which also brings a need for different labels or text strings, and for that we use the Joomla language manager. First we insert a constant into the component or template file. For the example I’ll use the index.php file. Inserting the constant is easy:
<?php echo JText::_(‘Custom_String’); ?>
Now we can go to the Joomla Language manager, click on the button New and insert the constant Custom_String into the Language Constant input field. We type our value and click Save.
If everything went ok, the custom value should show in the template or component.
Language overrides are a great and right way to create language overrides or create custom language strings. They give the option to change the existing translations or to create your own and insert them with php anywhere in your webpage. When updating Joomla you won’t have to worry about loosing your changes, because they are saved in a separate file. It is a great addition when using template, module or component overrides.