Add more languages to the application

By default, MX Kollection 3 offers only one language at a time for the error messages and the button labels. These texts are stored in files, and each time the language is changed from the InterAKT Control Panel, they are overwritten with the new ones. These files are stored in the \includes\resources folder in the site root.

In order to create a multilingual application you need to have more than one language available at a time. To generate the resources for more than one language, follow the next steps:

  1. Open a site page in Dreamweaver.

  2. Use the InterAKT Control Panel to change the site language. Open the control panel from the MX Kollection tab of the Insert bar and then select the Language settings option. From the drop-down menu select a different language from English (this will remain the default language) - say, German.


     

  3. Click OK to apply the new settings. You will notice that some file activity occurs - the old files are being overwritten with the German resources.

  4. If you preview the NeXTensio list in the browser right now, you will notice that the button labels changed:


     

  5. In order to save these resources, so that they will be used later on, duplicate the resources folder. In Dreamweaver select this folder in the Files tab, right-click on it and select Edit -> Duplicate. A new folder with the same files, named Copy of resources will appear in the Files tab:


     

  6. Rename the new folder, in order to append the language code to it (ger in this case). This code is the one that will be passed by the drop-down menu when a visitor selects the site language. Click on the folder name and press F2 on the keyboard. Enter the new name: resources_ger.



    Note
    : A dialog box will prompt you to update links pointing to the file. You can safely select the Don't update option.

  7. Repeat steps 2-6 until you have generated resource folders for all desired languages, except the one that will be used as default. Make sure to use the language codes, as they will be used later on.

  8. After generating folders for all languages, from the Language settings entry in the control panel select the one that will be displayed by default (when the user does not make a selection, or the selection is invalid). In this tutorial, English is the default language. Additionally, the site will also support French and German. Thus, the folder structure will be:

 

Once the actual resources exist, MX Kollection 3 must know to load only the desired ones. The logic is as follows:

  1. When a visitor selects a language from the list, the language code is saved as a session variable (language) for later use.
  2. When loading the resources, the code must check if a particular language has been selected. If yes, the resources folder name is built, using the static "resources_" section to which the language code is appended. This will result in the resources_ger or resources_fr folder names.
  3. Next, the code checks if the selected language folder really exists. If it does, the selected language is used. If not, the default resources are loaded.
 
The first part (saving the code to a session variable) will be handled in the following topic. The rest of the actions must be implemented directly into one of the MX Kollection 3 files: the one that loads the resources. To do so, follow the next steps:
  1. Open the \includes\common\lib\resources\KT_ResourcesFunctions.inc.php or .asp, or \includes\common\lib\resources\KT_Resources.inc.cfm in Dreamweaver. Use the extension corresponding to your particular server model.
  2. Locate the function KT_getResource, and within its code, the declaration of the dictionary file name. This defines from which folder to load the resources, and it should look similar to the following:
  3. By default, this line will load the dictionary files in the includes\resources\ folder. You need to change this code with the following (select the one corresponding to your particular server model):
  4. Save the file and upload it to the server. If you try and preview the list in a browser right now, you will not notice any differences. This is because no language has been set yet.
In the following topic you will create a code snippet that displays a drop-down menu with the languages you've added to the site, and sets the session variable accordingly.