Language Override Plugin

Many people have asked how to change the ways things are worded on their Elgg sites. For example, where the word friends appears, the word colleagues may be more appropriate. This is easily achieved by editing the languages/en.php file (In the case of English). The problem is that this is editing the core. If you are careless about your upgrade, all your customizations disappear. This is best achieved using an override.

The languageoverride plugin allows you to edit the file using a plugin, leaving the core intact. Simply download and unpack the plugin, then upload it to the mod folder. Now you can customize mod/languageoverride/languages/en.php to achieve the same thing. Of course, the customizations can be made before uploading.

Open the en.php file in a text editor. You will see a well commented, tidily organized file:

Click to enlarge

Find the text you want to change by browsing the appropriate headings of by using the find function.

Lets take a closer look at the friends section of the code.

Click to enlarge

Click to enlarge

If you look at the left side of the arrow, you will see the code that calls for a string of text to display. The text actually displayed to the user is on the right side of the arrow. For example:

‘friends:yours’ => “Your friends”,

The code ‘friends:yours’ displays Your friends. If you want it to display Your colleague, you would change the line to:

‘friends:yours’ => “Your colleague”,

Note that the text to the left of the arrow remains the same.

Sometimes you may see a %s sign in the message. This is a call to a variable.

‘friends:add:successful’ => “You have successfully added %s as a friend.”,

Had you just added “John” as a friend, the text displayed would be: You have successfully added John as a friend. Do not remove the %s! For our colleague example it would be changed to:

‘friends:add:successful’ => “You have successfully added %s as a colleague.”,

Once you have made the changes, save the file. Provided the plugin is activated, the new terms will display.

You do not necessarily have to use this plugin to achieve the changes. You could put a languages file in any number of existing plugins including themes. Merely create a language folder for the plugin and put the en.php file in the languages folder:

myplugin/languages/en.php

Make you changes to the en.php as you would with the plugin.

Some text may not reside in the languages/en.php folder. In some cases plugins have their own languages/en.php files extending the core. In that case, it is appropriate to edit the languages/en.php file for the individual plugin. I am not sure if there is a way to override the plugin’s language file. When upgrading a mod, be sure to save copies of any changes to language/en.php.

While this is a fairly simple plugin, I’m sure that many will find it useful. Download the file here.

Read the comments for more good information!

Related Posts

Tags: , , , ,

  1. Matt Leifer’s avatar

    This is a good idea and something I have already implemented on my site, but I wouldn’t recommend hacking plugin files too much because they are just as likely to be updated as the core.

    You can override the en.php files of plugins by just appending the contents to the en.php file in the languageoverride plugin. Well, not the whole file, but just the bit that contains the array assignments. Then just make sure that languageoverride is below any plugins that you have overriden the language settings for in the loading order.

    I think it would be better if languages worked a bit more like views where you could override individual files by placing them in an appropriate directory structure. Perhaps we can hope for this in future versions of elgg.

    Reply

  2. Steve’s avatar

    Good to know! Thanks for that!

    I agree with your thinking regarding languages functioning like views. I was poking around for anything that works along those lines, but I didn’t see anything.

    I’d like to see something like:

    languageoverride/languages/en.php
    languageoverride/languages/groups/en.php
    languageoverride/languages/blog/en.php

    or

    languageoverride/languages/en.php
    languageoverride/languages/groups/languages/en.php
    languageoverride/languages/blog/languages/en.php

    much as we see in views. Again, since I didn’t see anything like it I assume it wouldn’t work.

    Reply

  3. Matt Leifer’s avatar

    Indeed, I tried those combinations and nothing like that seems to work. Maintaining one en.php file isn’t too much of a big deal though, provided you are careful to comment which sections come from which plugins.

    Reply

By submitting a comment you agree to license your comment under the following terms: Creative Commons License


This comment will be licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.