Tutorial: How to change wording, How to change text, How to change language. How to change locale
How do I Translate or change a piece of text, is often asked on the forum
1. Finding Out What is Translatable via definitions/locales.
Generally anything in the core code or a plugin that is translatable will look like this
T("some piece of text!")
then all you need to do to change that text is to add a definition to one of your locale based files (see later explanation)
$Definition['some piece of text!'] = 'my changed piece of text';
notice how the left side of equation matches EXACTLY and the right side is your new translation or wording
if you see something like this
the %s stands for a string replacement. it must be included on the right side.
e.g. your definition could be any of the following
$Definition['%s comment']='%s Vietnamese post'; $Definition['%s comment']='my %s Vietnamese post'; $Definition['%s comment']='Spanish post %s';
notice the %s is on both sides of equation.
some definitions are not immediately recognizable. They may not have the words as you would think. Nevertheless they will be translatable.
$Definition['GuestModule.Message'] = "It looks like you\'re either new here or you have not logged in yet. If you want to participate in our community discussions, click one of these buttons!";
another example in the code you might see the word Plural(
echo '<strong>'.Plural($Discussion->CountUnreadComments, '%s New', '%s New Plural').'</strong>';
in this case...
you could change to completely get rid of the New designation.
$Definition['%s New'] = ""; $Definition['%s New Plural'] = "";
or make it
$Definition['%s New'] = "%s Nuevo"; $Definition['%s New Plural'] = "'%s Nuevo Plural";
the easiest way to get a list of almost all definitions is to download a locale addon. The language doesn't matter if you just want to get an idea of definitions used.
look in each of the files - some will have statements that start with
these are your definitions.
You can also figure out definitions via
So the idea is find out what is translatable either by looking at code and looking for T( statements
or looking at other locale plugins for definitions
or using the locale developer plugin.
If your forum is English based.
the easiest way to change definitions is via /conf/locale.php
you could change your /conf/locale.php by adding definitions to it.
<?php if (!defined('APPLICATION')) exit(); $Definition['%s comment']='%s post'; $Definition['%s comments']='%s posts'; $Definition['Howdy, Stranger!'] = "Greetings, Bucko!"; $Definition['GuestModule.Message'] = "It looks like you\'re either new here or you have not logged in yet. If you want to participate in our community discussions, click one of these buttons!";
or you could add them to the bottom of the definitions file of your locale (e.g. Vietnamese locale)
Precedence of definition type files
the precedence is as follows for definitions
you change or add a definition in one of the following files
the order of locales (the higher the number on the list, the higher precedence).
en-CA is a country code (substitute your own country code that you use
1 - application based and dashboard based definitions applications/locale/en-CA/definitions.php applications/dashboard/locale/en-CA/definitions.php 2- plugin based - plugins/yourplugin/locale/en-US.php plugins/your plugin/locale/en-US/definitions.php 3 - theme based - themes/yourtheme/locale/en-CA.php 4 - locale based - /locales/en-US/definitions.php 5 - locale based locales/en-US/other_definitions.php 6- conf based - conf/locale.php 7- conf - specialized conf/locale-en-US.php
so if you have a definition in this file
$Definition['Howdy, Stranger!'] = "Greetings, Bucko!";
and you have a definition in
$Definition['Howdy, Stranger!'] = "Greetings, Earthling!";
the Greetings, Earthling! will take precedence because
conf based file (conf/locale.php) is a higher precedence than applications (applications/locale/en-CA/definitions.php)
Another thing to note if you have multiple duplicate definitions in the same file
$Definition['Howdy, Stranger!'] = "Greetings, Bucko!"; $Definition['Howdy, Stranger!'] = "Greetings, Earthling!";
the last duplicated left hand side of the definition will rule.
if the Definition is like this
$Definition["You Can't do this"] = 'You Can't do this is bad - because the quoting is wrong'; // BAD $Definition["You Can't do this"] = "You Can't do this is good - because the quoting is right"; // GOOD $Definition['You "Can" do this'] = "But You "Can" not do this"; // BAD $Definition['You "Can" do this'] = 'But You "Can" not do this'; // GOOD
the gist is if you have a single quote in your definition escape it or wrap it in double quotes
the gist is if you have a double quotes in your definition escape it or wrap it in single quotes
when modifying locales or adding locale files - always clear the ini files in the /cache folder - for best results.
to see if you are reading the files you think you are reading for locales.
look at the contents of
if your locale file is not listed you are not reading it !
so if the cache/locale_map.ini
0 = "public_html/forum/locales/ViVN/definitions.php"
and you are wondering why your definitions in conf/locale.php are not being read, it is because you need to delete the
you can also do mobile specific defintions... see
you can also see localization
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.