Changing Language on the FST Form

By on June 5th, 2022 in FST HInts, FST New Features

FST Version 14 introduced the feature of allowing alternate language messages on the form. This is done with an array called $FST_LANG_TEXT. Just like other FST settings, you can re-define this setting according to your needs. For instance, you could create an alternate form in Spanish for your Spanish-reading visitors.

The $FST_LANG_TEXT setting is a two-dimensional array. Here’s one element of the array – you can see all of them on this page. (The contents of that page- the various text strings used in your form – are taken directly from the FST functions file where the default English language values are defined.

Here’s one element of that array:

    "incomplete_message" => "Whoops! There is some incomplete or incorrect information"

Inside the FST functions file, that message is displayed with a command similar to this

    echo FST_LANG_TEXT['incomplete_message'];

That array first defined as $fst_lang_text. You can override any value in that array by placing commands similar to this in your FST_MORE_FIELDS function of your form’s page code

    global $FST_LANG_TEXT;    
    $FST_LANG_TEXT['incomplete_message'] = "You forgot something!";

(Note that although $FST_LANG_TEXT was introduced in version 14, there were some issues with implementation. It turns out that PHP is picky about the case of variables, and version 14.00/15.00 had some lowercase instances of that variable. This was fixed in version 15, released 5 Jun 2022.)

When the FST_MORE_FIELDS function is loaded by the main functions file, any values in there (since they have been GLOBAL‘d) are first sanitized. Then your $FST_LANG_TEXT value is merged with the default array. And then, the $FST_LANG_TEXT array is converted into a constant via the DEFINE command.

With this new feature, you can set the front-facing text messages to whatever language you want. Note that FST doesn’t have multiple language support, so if you need two forms with different languages, you’ll need two separate form page files.

Note also that all variables in FST_MORE_FIELDS need to be upper-case. A lower-case setting, like “GLOBAL $fst_lang_text” won’t work, since the variable’s case is different.

Let us know what you think in the comments below. And use the Contact/Subscribe page to sign up for our occasional newsletter. We don’t share your information with others.

 

 

Add Your Comment

We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our comment policy. Required fields are marked with a red asterisk (*).

Use the buttons to format your content. Use Shift+Ctrl+V to paste text. Use Ctrl+RightClick to see spelling suggestions. We suggest that you keep any fancy formatting to a minimum.

Please carefully review your comment before submitting.