glFusion Wiki

Site Tools


Language Customizations

There may be times where you would like to use different text strings than what is provided by glFusion. For example, you might want to change the menu entry for Media Gallery to Gallery. glFusion provides a very flexible customization system that allows you to make language customizations and make sure your changes are not overwritten during upgrades.

Overriding Text - Media Gallery Example

The process is very simple, you simply create a custom language file with just the items you want to override. For example, to change the Media Gallery prompt to Gallery, you would create the following override file:

Create private/plugins/mediagallery/language/custom/english_utf-8.php (or whatever your language name is).

Place the following in the custom file:

      $LANG_MG00['menulabel'] = 'Gallery';

This will override the default $LANG_MG00['menulabel'] entry in the stock language file.

Overriding glFusion Text

Another example might be if you wanted to change the string Continue Reading to something like Read the Rest of the Story.

We'll assume we are using the standard english_utf8.php language file located in the private/language/ directory for this example.

  • First we'll create our custom english_utf8.php file in the private/language/custom/ directory. The file should look like this (note we haven't added any customizations yet):
  // custom english_utf8.php file
  • Now we want to find the Continue Reading text in the standard english_utf8.php file - upon a little searching we see it is part of the $LANG01 variable and referenced as 'continue_reading'. So we'll add a new line to our custom language file:
  $LANG01['continue_reading'] = 'Read the Rest of the Story';
Our entire file should look like this now:
  // custom english_utf8.php file
  $LANG01['continue_reading'] = 'Read the Rest of the Story';
  • We'll save the file now as we are done with the customizations.
  • Since several things in glFusion are cached - we'll go into Command & Control and clear the cache to ensure our new customization is now used.

That's it!

Creating New Language Variables

There may be times when you want to create a new language string. For example, you may want to have something different in the “continue reading” button of the featured story than what is in the not featured stories.

This is a 2 step process - first you'll want to add your language string to the custom language file - for example:

  // custom english_utf8.php file
  $LANG01['continue_reading_featured'] = 'More Information';

Now we have our custom language string setup - we need to update the featuredstorytext.thtml template to use the new language string.

Without going into too much technical detail, generally adding template variables is something that is done in the PHP code. You'll see stuff like:

    $T->set_var('lang_continue_reading', $LANG01['continue_reading']);

This is how lang_continue_reading was set for the template.

We do not want to update or tinker with the PHP code, so how can we get our new language string into the template? Actually, it is pretty simple, we can reference the $LANG01 variable directly in the template.

  • Because we always follow best practices, we'll first create a copy of the featuredstorytext.thtml file in the custom/ directory so our change will not be overwritten when we upgrade glFusion.
  • Next we'll log our customization in the sitelog.txt file (you do keep track of your customizatons, don't you?
  • Now we'll edit our custom/featuredstorytext.thtml file and change the line that references {lang_continue_reading} to look like this:
    <a class="uk-button uk-button-primary" href="{readmore_url}">{$LANG01[continue_reading_featured]}</a>
  • Save our customization.
  • Since several things in glFusion are cached - we'll go into Command & Control and clear the cache to ensure our new customization is now used.

Now we are using our own custom language tags in our custom template.

If you have users that use other languages, you may want to add a translated version of your customization to the other language files.

Important Notes

Language file overrides only work when there is a corresponding language file in the actual language/ directory. For example, if you wanted to have your Media Gallery display in 'piglatin_utf-8.php', you must first have a 'piglatin_utf-8.php' file in the private/plugins/mediagallery/language/ directory. Since Pig Latin is not a language that is included with Media Gallery, you really don't need to have an override file. In this example, we (the glFusion Team) would appreciate you sending us the Pig Latin translation so we could include it in future releases.

glfusion/language/customizing.txt · Last modified: 2017/01/18 09:46 (external edit)