Did you know that you can translate any of the default text on your Joomla site without touching the core language files? The feature that makes this possible is called "Language Overrides". In this tutorial, we'll show you how to use the "Language Overrides" to change a single text string.
A language string is composed of two parts: a specific language constant and its value.
The COM_OSCAMPUS
to the left of the equal sign in the image above is a language string constant. The OSCampus Pro
text to the right of the equal sign is a language string value.
The constant is needed for Joomla code. The value is the very text which will be displayed in a label.
Without this feature, if you wanted to write your own labels and text messages you need to actually go to your /language/ folder and replace language strings.
You now don't need any knowledge of coding to change a text of your Joomla labels. It doesn't affect the core files. Delete your changes and revert back. It is just a piece of cake!
For the purpose of this tutorial, you will replace the "Become a member to view this session" text for your OSCampus Pro sign-up page by its string.
First let's acess the language overrides
- Go to Extensions > Language(s) > Overrides:
You will see the Languages: Overrides administrative page:
- Click New.
You will see the Languages: Edit Override administrative page:
- Locate the Search For field. Make sure the field displays the Value option:
- Enter Become a member into the Search field.
- Click on the blue Search button:
You will see the string and its text appeared in the Search Results box:
- Click anywhere inside that box.
- You will see the text "Become a member to view this session" appeared in the Text box. Replace it with the one you prefer.
- Click Save & Close.
You will be taken to the administrative Languages: Overrides page with your new override listed:
If you would like to further tweak the text of your newly created language override, simply click on the constant:
You will be once again taken to already familiar to you Languages: Edit Override administrative page.
- Edit the language string text inside the Text box.
- Click Save & Close.
Adding Images to Language Strings
One Joomlashack user asked if they can include images in language overrides. The answer is: "Yes, you can but you may not need to."
Technically, the Language Override allows you to place HTML tags, such as the img
either inside or instead of your language text strings. If you want, you can edit your Language Override to end up with the string looking similar to the one in the image below:
However, the best approach with content management systems is normally to keep your content separate from presentation. Before you do this, check to see if you have better ways to get the same result.