Text variables - explained

From TNG_Wiki
Jump to navigation Jump to search
Ambox notice.png The Text variables - explained provides a brief description on how text variables are used within TNG. You can override the text variables in your cust_text.php files.
TNG All


TNG uses $text variable arrays for substituting the various language text strings in the

  • TNG-generated pages
  • TNG pull down menus
  • the navigation menus in the template's topmenu.php file
  • the TNG footer.php file.

Each TNG page will define its text variables by including either text.php or admintext.php, both of which include other files as noted below. These are duplicated for every language that TNG enables, so to find these files, look in, for instance:

  • languages/English/
  • languages/French-UTF8/

Each definition contains a "message name" and a "message string". e.g.

$text['newsearch'] = "New Search";

When these are translated into another language, it's important to leave the message name unchanged and to copy any capitalisation or spaces. e.g.

$text['newsearch'] = "Nouvelle Recherche";

text.php

The text.php file in each language folder defines the language specific $text variables used in the TNG public pages for that language by

  • defining a group of text strings common to all public pages
  • defining a group of text strings switched by the variable $textpart (defined by the calling program) to create strings specific to the public page being created
  • including once captcha_text.php – Brian McFadyen's TNG captcha mod language specific text if the file exists
  • including once alltext.php – the TNG text variables used in both public and admin pages.

The captcha.text.php provides the text for the optional TNG captcha provided in the newacctform.php and suggest.php files.

alltext.php

The alltext.php file in each language folder

  • defines the common variables used by both the admin and public side of TNG
  • defines the $dates array variables
  • defines the $text variables used on both the public side and admin side of TNG for that language
  • defines the $admtext variables for Google maps
  • includes the contents of
    • languages/English/cust_text.php (for all non-English languages)
    • cust_text.php – the user cust_text.php in the specific language folder

English overrides

The purpose of including the English version of cust_text.php (which happened in v10 a replacement to Roger Clist's Custom_Text_Files_Mod) is to cater for mods or local changes which have not been extended to cover that language. If they have been, the language version will supersede the English.

Note If you add overrides in your English or English-UTF8 cust_text.php, you must add the text variable overrides in all the other languages cust_text.php files used on your site


For example, if you override the alltext.php $admtext['CHR'] = "Christening"; text variable to use $admtext['CHR'] = "Baptism"; because you entered your baptism events in the CHR event field in PAF, you will need to add $admtext['CHR'] = "Baptême"; to your French or French-UTF8 cust_text.php file to prevent the English or English-UTF8 cust_text.php value from being displayed when switched to French even though the alltext.php already contains the correct value.

The logic was added to alltext.php in TNG v10 to display the English cust_text.php variable in other languages so that mods that provided Englisth text only would have a value displayed.

admintext.php

The admintext.php file in each language folder defines the language specific $admtext variables used in the TNG admin pages for that language by

  • defining a group of text strings common to all admin pages
  • defining a group of text strings switched by the variable $textpart (defined prior) to create the strings specific to the admin page being created
  • including once alltext.php – the TNG text variables used in both public and admin pages.

cust_text.php

The cust_text.php in each language folder is included as the last file in alltext.php and so it can override $text, $admtext and $dates variables for that language whether they are in

  • admintext.php,
  • alltext.php, or
  • text.php.

The cust_text.php files define custom text variables used by your site, that is, your own user-defined $text variables. Each language folder (of languages used by your site) should have a cust_text.php file with suitable translations of your custom text variables for that language.

Note that the cust_text.php files may not exist in language-specific folders on an initial install of TNG. Therefore if you have a multi-language TNG site, it is not sufficient to have cust_text.php in the languages/English folder only - you need to create cust_text.php files in each languages/(language) folder being used. If your pages reference text variables that are undefined, the page will have omitted words and read incorrectly. You may not notice the omissions as error messages are unlikely to be generated.

If you need foreign language translations of words and phrases, you will likely find help from a friendly person in the TNG community. You should provide your helper with a link to the page containing the words or phrases needing translation, so that the context is clearly understood.

The cust_text.php file includes variables added by TNG Mods using the Mod Manager

Mod developers should put their $text variables prior to the following lines:

//Mods should put their changes before this line, local changes should come after it.


Foreign-accented characters

Foreign-accented characters can be entered as-is within the above files, provided the files are saved in the correct encoding for the charset used on your web site:

  • ANSI is the default encoding for the TNG provided files for charset=ISO-8859-1. The MySQL name for this is typically latin1-swedish_ci.
  • UTF-8 versions of the text variable files are provided for use with charset=UTF-8
  • Extra files needed to use PDF reports in a UTF-8 environment may be downloaded by TNG site owners from the TNG downloads site (see TNG Extras section).

Note that if you want to UTF-8 charaters in your database - not just in language strings displayed for people outside of the USA:

  • your database MUST be defined as utf8_xxxxxxxx_ci (where the x's stand for "general" or the language mostly used and "ci" means "case insensitive") and
  • your desktop genealogy program must export a UTF-8-encoded gedcom file without BOMs. See PAF#Export UTF8 for a PAF export example.

The collation rules (governing sorting) in MySQL are quite subtle and ensure that (a) Upper and lower case sort together (b) language-specific rules are followed. e.g. in French "é" sorts next to "e" and in German "ß" sorts with "ss". The "ci" also ensures that upper and lower case are considered equal in matches. Avoid "bin" as this ignores all such rules.

Related links