Joomla is a multi-language CMS, It’s built and engineered in a manner that let’s you serve multiple languages of audience on your website using the same code base. i.e. You can create content for English and French in the same site and serve both the users under the same domain. Ofcourse, you do it by creating content and menu items specific to the user’s language but there are other global elements/pages that can be changed within Joomla’s core and that’s where language constants and this tutorial comes in.
Let’s take an example for the login screen below.
The login module or the component gives you very little control over the language of the page. Let’s imagine for instant you want to change the text of the button Log in to Log me in!. You can’t do it from login module but you sure can do it using the language overrides manager.
There are 2 steps involved in this process:
- Locate the language CONSTANT (i.e. Log In in reality is something like COM_USERS_LOGIN_BUTTON and this is the constant).
- Go to the language overrides manager and add an override for the constant for the language of your choice.
To easily locate the constants we can turn on language debug in the Joomla configuration, which would start displaying all the constants instead of values in the frontend (this would make your site look a little weird, so if it’s a high traffic site, don’t do it in production).
This is how you enable the language debug in Joomla.
Login to your Joomla backend.
Navigate to System >> Global Config >> System Tab
In there, turn Debug Language to Yes and change Language Display from value to constant.
Starting Joomla 3.7 or so, you are now able to see the language constants as well (not just the value) to help you locate the exact constant and create overrides rather than just trying to search for constants in the the language overrides manager.
Save your settings and then refresh the frontend, you’ll see a page similar to the one below.
As you can see it’s now displaying all the constants instead of the values (your Joomla backend will also be a little weird since that would also have constants instead of values).
The ** in the beginning and the end are there to prove that this is a valid language constant so you can safely ignore that. Now we know that the constant for our login button is JLOGIN, Let’s turn off the language debug and head on over to the Language Overrides manager to create an override.
Now Let’s head over to Extensions >> Language >> Overrides
On this screen, select the language you’d like to add overrides for. I’ll be adding the overrides for English (en-GB) – Site, so we’ll select that.
After selection click the New button on the top left to create a new override.
On the above screen you can create overrides on the left (which, we’ll do) and on the right you can search for constant (If you followed the tutorial all along, we have already done this and you can safely skip this).
In the language constant input type JLOGIN and in the text type Log me in!
Hit save on the top left and then refresh the login screen on the frontend, you’ll see the button now reads Log me in! and that’s as simple really how you create language overrides.
You can create as many overrides you like for all languages installed.
Watch the video below for more: