Lazarus Guest Book - Multi-lingual Installation

From TNG_Wiki
Jump to navigation Jump to search

Lazarus Guest Book and TNG

First of all, you can see how it works

Access my website at www.ourfamilylinks.org[1] Any questions, please send me an e-mail -- ChuckFilteau@gmail.com


Obtaining the Lazarus Guest Book

First of all, you must obtain the Lazarus Guest Book files from http://carbonize.co.uk/Lazarus/download.php and store them on your PC

  • Be sure to download the additional languages if your TNG site supports languages other than English


Creating the Lazarus folder at your TNG server site

  • Go to your server and create a folder (let's call it lazarusgb) on the same folder level that you used to install your TNG product.

I prefer to send the zipped file(s) to my server and unzip them at the server level, but you might prefer to unzip them on your pc and download each of the files and folders separately.

  • Upload all the lazarus files to the lazarusgb folder
  • Unzip them, if necessary, in that same folder


Word of caution when making changes to files

  • you must always make a backup copy of any file you expect to modify, just in case you make an error.


If you have multi-language support in TNG

This step can be skipped if your site is only supporting one language.

You must add language-dependent text to each TNG language folder

  • For each language folder (English, French, etc) you must edit the cust_text.php file

  • Some versions of TNG only have the cust_text.php file in the primary language folder. All you need to do is to copy the original cust_text.php file into each of the secondary langage folder(s). Of course, you will need to edit each of them to provide the corresponding translation from one language into another.

Here is an example of the cust_text.php file in the English folder:

// Text to appear in the TNG menus for the linkage to the Guestbook
$text['MYgblink'] = "Guest Book";
// Text to appear in the title on the Guestbook page:
$text['MYgbtitle'] = "Welcome, please sign our Guest Book"; 
global $rootpath; 

Here is an example of the cust_text.php file in the French folder:

// Text to appear in the TNG menus for the linkage to the Guestbook
$text['MYgblink'] = "Signez notre Livre d'or";
// Text to appear in the title on the Guestbook page:
$text['MYgbtitle'] = "Livre d'or de OurGenealogySite.com";
global $rootpath; 
  • Be sure to SAVE the file, and then repeat the same process for each language folder, using the correct language for the text inside the double-quotes.

Creating a php file in TNG to access your guest book

  • Using the folder that you used to install TNG
 Create a new file (let's call it Ourguestbook.php)
* Edit that file, using the following example.

Note - I obtained the following example from Ken Roy and modified it slightly
(I put a horizontal rule under the tng_coreicons)

  • Note the include for the lazarusgb/gbinclude.php

<?
include("begin.php");
include($cms[tngpath] ."genlib.php");
include($cms[tngpath] ."getlang.php");
include($cms[tngpath] ."$mylanguage/text.php");
tng_db_connect($database_host,$database_name,
               $database_username,$database_password) or exit;
include($cms[tngpath] ."checklogin.php");
// * * * * 
// tng_header( "$text['MYgbtitle'] ", $flags ); 
// If using multiple languages in TNG, use the example above 
// to change the line below
   tng_header("Welcome, please sign our Guest Book",$flags );

echo tng_coreicons();
echo "<hr>";
?>
<p class="header">  </p>
<?php
// NOTE - the original include had 2 dots in front, i.e., ../lazarus ...
// YOU might need the extra dot 
include('./lazarusgb/gbinclude.php'); ?>

<?php tng_footer( "" ); ?>
  Be sure to save it! 


Testing your newly defined GuestBook panel

  • at this point in time, you only want to verify that your GuestBook can come up in English.

  • you should be able to test your TNG guestbook panel directly from the file manager on your server
  • Or you can test it from your browser on your pc by opening a new window (or tab) and keying the complete url path to your guest book
http://www.yourwebsite.com/Ourguestbook.php

or

http://www.yourwebsite.com/tng-install-folder/Ourguestbook.php

  • If you get any errors, go back and make the appropriate corrections.

Modifying the TNG files so that it can access your guestbook panel

  • Modify the index.php that belongs to your TNG installation and any other secondary php files, as necessary.

Somewhere, in an appropriate place on TNG's home panel, insert the following text:

use the following code if your TNG uses only one language

echo "<li><a href=\"Ourguestbook.php \">Please sign our Guest Book</a></li>\n"; 

OR use the following code if your TNG site is multi-lingual

echo "<li><a href=\"Ourguestbook.php \">$text[Mygblink]</a></li>\n"; 

  • be sure to save the file after you have changed it


Verifying you can access the guestbook from your home panel

  • Using your browser, access your web site
  • Select the guest-book-linkage that you just added to your menu


Congratulations. You have successfully installed the Lazarus Guest Book with TNG. At this time you are finished with the TNG update process if your site supports only one language.

The Lazarus Administration function is an entirely different matter. It can control if and how CAPTCHA is used, among other things. Hopefully, someone (maybe me in the near future) will post that information in this forum.

  • Hopefully, you will have no errors; otherwise, you will have to go back and fix any errors in the file(s) and test it/them again.

  • But there is still more to do if your TNG site is multi-lingual.


Determining the name of the cookie that TNG sets when a user has set a language in TNG

Apparently, various releases of TNG and various servers use different styles of naming conventions for cookies.

  • So here is my solution to determine the name of the cookie that contains the language

First of all, you need to get a copy of Firefox and install it on your computer

  http://www.mozilla.com/en-US/firefox/

Then you need to install a copy of some web developer tool that will let you see "stuff" such as cookies. I used http://chrispederick.com/work/web-developer/
Note - the web developer toolbar can be toggled on/off by accessing View/Toolbars at the top of the Firefox window

  • Now that you have the tools, let's proceed to discover the name of your language cookie

1) Using the Firefox browser (not IE) access your TNG website and set the language to English or French or some other language.
2) On the Web developer toolbar, click on the Cookies pull down and select View Cookie Information.
3) that will activate a window in another tab.
4) Inspect that output looking for a cookie that has a name starting with "tnglang..."

Name	tnglang_varwwwweb93htmlxxxxxxcomv4
Value	French
Host	www.xxxxxx.com

OR

Name	tnglang_homesitelocpublic-htmlgenealogy
Value	French
Host	www.xxxxxx.com

5) the Value of that cookie should be the same as the language you chose in your TNG session
6) copy the text following the name of that cookie
(you will need it to make Lazarus multi-lingual)

Making the Lazarus Guest Book multilingual

TNG uses a capital letter for its language (such as French).
Lazarus uses a lower case letter for its language (such as french).

  • The following information worked for me. I hope it works for you.

Unfortunately, the post on the Lazarus web site has some incorrect information:

  http://carbonize.co.uk/Lazarus/Forum/index.php?topic=1256.0

The process described is correct, but the cookie that is named is incorrect.

  • Here is the correct modification to the Lazarus code

open the lazarusgb/lib/vars.class.php and replace the following 4 lines of code:

if (isset($_COOKIE['lang']) && !empty($_COOKIE['lang']))
{
$this->template->set_lang($_COOKIE['lang']);
}

with these 5 lines of code: ('paste' the cookie name (copied from above)
into the paste-the-cookie-name-here in the code below

$cookiestring = "paste-the-cookie-name-here"; 
if (isset($_COOKIE[$cookiestring]) && !empty($_COOKIE[$cookiestring]))
{
$this->template->set_lang(strtolower($_COOKIE[$cookiestring])); 
}

Note the extra ( ) because of the strtolower function

  • Be sure to save the changes.
  • Additional Information about the $cookiestring text.
The first part of the string is usually something like
"tnglang_home"  or   "tnglang_var"
The last part of the string is the path name to your TNG application: 
It will usually be three levels if you installed TNG into a folder (e.g, genealogy)
or only two levels if you installed TNG without using a folder.

And that is all there is to do. By now it should be working.

  • Try it out and verify that any language switch you make in TNG will always change the language in the Guestbook and vice versa.


I hope this helps you avoid all the aggravation I had when I tried to make it work.

Aside - Maybe someone can get this to work

1) The language definition in TNG is capitalized, (i.e., French);
the language definition in Lazarus is lower case, (i.e, french).

2) A simple solution to the uppercase/lowercase problem might be a simple name change to the files.

Keep  the upper case naming convention used by TNG and

rename  all the Lazarus php files from

     english.php         to  English.php
   and
     codes-english.php   to  codes-English.php

and apply the same naming style to every other language files.

If that were done, the strtolower function might not be needed.
3) Another possible, much simpler, solution might be able to eliminate the access to the TNG cookie.

  • The above solution to make Lazarus multi-lingual depended upon access to a COOKIE and you must know the name of the cookie.

But, internally, TNG also sets a global variable called $mylanguage whenever it creates the cookie. So the question is: could the variable $mylanguage be used instead of accessing the cookie by name?
I tried a couple of different ways, but could not make it work. But maybe someone else will come up with a simpler way to set the Lazarus language.