Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How-to guide: Using FormMail with more than one language

  1. #1
    Join Date
    Nov 2009
    Posts
    14

    Default How-to guide: Using FormMail with more than one language

    FormMail supports "language packs" for use on sites written in languages other than English. The language packs work because FormMail is written to look for a file named "language.inc" and to use that file for replacing the English messages in FormMail with translated messages. Thus, one installs a language pack merely by downloading it, unzipping it, making sure the language pack for the desired language is named "language.inc" and placing it in the same directory as FormMail.

    Although this approach works, it does not provide for a way to use FormMail on sites with multiple, selectable languages. If one has developed a site where the content for different languages is kept within separate directories, the use of FormMail with each of the languages may be achieved by having separate copies of FormMail in each of those directories, along with the appropriate language pack for each directory. Of course, that also means that each page of the site would have to be duplicated into each language and maintained separately, which is terribly inefficient, since changing the structure of a single page will actually require several edits. That is why such sites are often designed with PHP and MySQL so that there will be only one copy of each page, and the various texts will be filled from the appropriate language's database entries. For such sites, there are no separate directories for each language - everything is more neatly and efficiently contained within a single directory, but that means the usual FormMail approach of having only one "language.inc" file will no longer be adequate for providing translations usable for the site's other languages.

    Here, then, is a simple way to get FormMail to work on sites that use multiple languages without having separate directories.

    Before getting started, is is presumed that whoever will be doing this will have enough programming experience to perform the following steps without messing up something else. These steps involve making a few simple changes to the FormMail script, itself, so I claim no responsibility for the actions of anyone who chooses to do this. All I shall say is that these are the steps that I took, and it DOES work for me. As with any such task, you should make backup copies of your files (especially of FormMail) BEFORE performing the following steps. That way, if you mess up, somewhere, you will be able to get back to your original configuration easily.

    Okay. Let's get started. The instructions are split into three parts: the language packs, the formmail.php script, and your own forms.:

    Language Packs:
    1. Download the language packs you wish to use.
    2. Unzip each one, and make sure each pack contains a file named "language_XX.inc" where "XX" is the standard, two-letter code for the language it contains (e.g. "fr" for French). Note that the code may be more than two letters if a specific dialect was used (e.g. "es-ar" for Argentinian Spanish). Be sure to take note of these codes.
    3. Be sure NOT to have a file named "language.inc" whose name does not include the language code. If necessary, rename "language.inc" to conform to the naming convention mention in step #2.
    The formMail.php script:
    1. Find the line that contains the code:
      PHP Code:
      $sLangID ""
    2. BEFORE that line, insert the following code:
      PHP Code:
      //
      // Check for language setting in URL
      //
      $langcode $_GET['langcode'];
      if (!isset(
      $langcode)) {
          
      //
          // Default to English
          //
          
      $langcode "en";

    3. Find the line that contains the code:
      PHP Code:
      function LoadLanguageFile() 
    4. Add "$langcode" to the list of global declarations within the function definition:
      PHP Code:
      global  $aMessages,$sLangID,$sHTMLCharSet,$langcode
    5. Change the first "@include" line to make use of the language code:
      PHP Code:
      if (!@include("language_" $langcode ".inc.php")) 
    6. Change the second "@include" line to make use of the language code:
      PHP Code:
      @include("language_" $langcode ".inc"); 
    7. Save the changes you have made to the formmail.php script.
    Your forms:
    1. In your forms, specify the action so that it will pass the appropriate language code to the formmail.php script (note that this example is from a PHP file where the language was already being specified in the variable $lang. Change this, as necessary, to suit your own code.) :
      PHP Code:
      action="http://www.mysite.com/formmail.php?langcode=<? echo $lang?>"
    Suggestion:
    • Since the REQUIRE_CAPTCHA string is NOT part of the $aMessages array, it is not able to be changed by this method. For that reason, I would suggest using conditions, instead of a "require" specification, then making your own messages for the condition where the user didn't enter anything for imgverify. Here's an example from my own form, where I defined my "conditions" messages in a two-dimensional array where the first subscript is the name of the error, and the second subscript is the language code:
      PHP Code:
      <input type="hidden" name="conditions05" value=":##TEST#imgverify#<? echo $fmerror['image'][$lang]; ?>#" />
    There you have it! It may sound like a lot, at first, but it's actually very simple, especially if you have already written your own php scripts to make use of the language codes.

  2. #2
    Join Date
    Mar 2009
    Posts
    9

    Default Re: How-to guide: Using FormMail with more than one language

    Kiba, thanks for this very helpful reply!

  3. #3
    Join Date
    Aug 2010
    Location
    nc
    Posts
    1

    Default Re: How-to guide: Using FormMail with more than one language

    Thanks alot for the information I was having trouble with formmail I was about to pull my hair out. I looked all over for this info

  4. #4
    Join Date
    Jan 2009
    Posts
    24

    Default Re: How-to guide: Using FormMail with more than one language

    Thanks, for this help full how-to.

  5. #5
    Join Date
    Jan 2011
    Location
    UK
    Posts
    1

    Default Re: How-to guide: Using FormMail with more than one language

    it was very difficult to understand but finally i managed

  6. #6
    Join Date
    Jan 2006
    Posts
    9

    Default Re: How-to guide: Using FormMail with more than one language

    I have a very basic problem with starting this - I've downloaded the language pack , but WinZip won't unzip it - says it doesn't recognize the format. Any ideas?

  7. #7
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: How-to guide: Using FormMail with more than one language

    Hi,

    Yes, others have reported problems with some versions of Windows and downloading attachments from vBulletin forum posts.

    We have all the language packs Zipped into one file in our public_downloads area:Let me know if you still have problems accessing them and I'll email them to you.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  8. #8
    Join Date
    Feb 2011
    Posts
    1

    Default Re: How-to guide: Using FormMail with more than one language

    I have problems getting emails in Russian with formmail. I followed your instruction:
    1) I uploaded Russian language.inc to the Formmail directory
    2) I added to formmail.php :
    / Check for language setting in URL
    //
    $langcode = $_GET['langcode'];
    if (!isset($langcode)) {
    //
    // Default to English
    //
    $langcode = "en";
    }
    $sLangID = "";

    And

    function LoadLanguageFile()
    {
    global $aMessages,$sLangID,$sHTMLCharSet,$langcode;
    AddIncludePath();
    if (!@include("language_" . $langcode . ".inc.php"))
    @include("language_" . $langcode . ".inc");
    ResetIncludePath();
    if (isset($sHTMLCharSet) && $sHTMLCharSet !== "")
    header("Content-Type: text/html; charset=$sHTMLCharSet");
    }
    3)I changed the first string of the form in the HTML
    <form method="post" action="http://mysite.com/formmail/formmail.php?langcode=<? echo $lang; ?>" name="SampleForm">

    As result I got the following email:


    FullName: СРРРє
    EmailAddr: contact: Y
    mesg: РјРјРјРјРјРјРјРРРРРРРРРРРР


    Thanks in advance

  9. #9
    Join Date
    Jan 2006
    Posts
    9

    Default Re: How-to guide: Using FormMail with more than one language

    Thanks Russell - the composite file unzips fine.

  10. #10
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: How-to guide: Using FormMail with more than one language

    Hi,

    Quote Originally Posted by origen View Post
    I have problems getting emails in Russian with formmail. I followed your instruction:
    The original poster (Kiba) created this thread to explain how to use multiple language packs with the one copy of FormMail.

    If you don't need to to that, then restore to the original copy of FormMail, and just install the Russian language pack as "language.inc.php".

    FormMail will automatically use the language pack if it's installed correctly.

    You don't need to alter or configure FormMail in any way for normal single-language operation.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Simple How-To guide attached
    By hmag in forum Community Support
    Replies: 33
    Last Post: 30-Jun-2012, 02:16 AM
  2. Help FormMail and arabic language
    By wissamyamout in forum Community Support
    Replies: 3
    Last Post: 31-Mar-2008, 06:54 AM
  3. FormMail Language Packs
    By russellr in forum FormMail
    Replies: 0
    Last Post: 16-Jun-2007, 02:57 AM
  4. Where is the formmail user guide ??
    By garyeqm in forum FormMail Subscription Support
    Replies: 2
    Last Post: 15-Dec-2005, 12:07 PM
  5. Error messages in other language than English.
    By minorarias in forum FormMail Subscription Support
    Replies: 4
    Last Post: 03-May-2005, 09:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •