How to translate Fast Secure Contact Form – PHP Script

Posted by on Sep 12, 2010 in How To

Language Translations

How to select a language: (there are 3 ways)
1) Setting a Default Language: The default language can be selected by visiting “Site Settings” on the admin page top menu. There is a form select to select a language by country locale.

2) Manually set a form to a specific (non-default language):

Edit the PHP code in the HTML body section of the page where your form is located:
Just after this:
$contact_form = 1; // set desired form number
add this:
$contact_form_language_override = ‘en_US’; // manual override for default “site settings” language

Be sure to change en_US to your desired language.

3) This program can also take a URL parameter to change the language:
?lang=it_IT or ?lang=it (Italian)
?lang=en_US or ?lang=en (English)

You are welcome to make a new translation.
The language files are stored in the folder /contact-files/languages/
Each available language will have a folder set located there.

Here is an example of the Italian language folder structure:
/contact-files/languages/it_IT/LC_MESSAGES/fsc-form-it_IT.po
/contact-files/languages/it_IT/LC_MESSAGES/fsc-form-it_IT.mo

The master file of strings to translate is located here:
/contact-files/languages/fsc-form.pot
This file is updated for each new version release.

gettext files are used for language translation localization. There are three types of files used in the gettext translation framework. These files are used and/or generated by translation tools during the translation process, as follows:

fsc-form.pot file: This is the master file of strings to be used by a person who will make or update a translation. The first step is the developer makes this file new for each upgrade version.

.po file: Named like this fsc-form-[locale].po, example: the Italian locale is it_IT, so you have: fsc-form-it_IT.po The second step in the localization process is that the translator translates all the messages from the POT file into the target language, and saves both English and translated messages in a PO file.

.mo file: Named like this fsc-form-[locale].mo, example: the Italian locale is it_IT, so you have: fsc-form-it_IT.mo The final step in the localization process is that the PO file is run through a program that turns it into an optimized machine-readable binary file (MO file). Compiling the translations to machine code makes the localized program much faster in retrieving the translations while it is running.

How to translate a NEW language?
There may already be translation in your language, check before you start! Look in the /contact-files/languages/ folder.
Languages can be selected by visiting “Site Settings” on the admin page top menu.
There is a form select to select a language by country locale. If the locale you need is not available, continue…
Look in the /contact-files/languages/ folder
The country code is part of the folder structure and file names.
Example for Italian: it_IT. The Italian files would be located like this:
/contact-files/languages/it_IT/LC_MESSAGES/fsc-form-it_IT.po
/contact-files/languages/it_IT/LC_MESSAGES/fsc-form-it_IT.mo

Create the folders you need for your new language files (be sure to change it_IT to the correct locale).

Translating With Poedit:
If there is not already a translation in your language, you may continue.
You should download the free Poedit program to translate, because it makes it easier to translate. http://www.poedit.net/

Locate the plugin POT file /contact-files/languages/fsc-form.pot
Getting the latest one from the latest download package is recommended. Save the file fs-contact-form.zip to your computer, unzip and locate the /contact-files/languages/fsc-form.pot file.

Open the pot file in Poedit. Click File – New Catalog from POT file.
translating-with-poedit

Entries are arranged in a list, so that you can easily navigate large catalogs and immediately get an idea about how big part of the catalog is already translated, what needs translating and which parts are only translated in a “fuzzy” way. Fuzzy and untranslated records are highlighted and displayed at the top of the list. Start at the top of the list and translate each line working your way downward. When done translating click Save.

Poedit will automatically save the .mo and .po files needed by this program. Be sure to name them like this:
Example for Italian: it_IT.
fsc-form-it_IT.mo
fsc-form-it_IT.po

Copy the language files into the folder: (create the proper folders)
Example for Italian: it_IT. The country code is part of the file name. The Italian files would be located like this:
/contact-files/languages/it_IT/LC_MESSAGES/fsc-form-it_IT.po
/contact-files/languages/it_IT/LC_MESSAGES/fsc-form-it_IT.mo

How to select a default language:

Languages can be selected by visiting “Site Settings” on the admin page top menu.
There is a form select to select a language by country locale.

When you have completed a new translation, please contact Mike and request to submit your language files to be included in the plugin download. Be sure to include your name and your web site URL for the credits.

Do you need help?

Send us a Donation:

Donate to Mike Challis