User Tools

Site Tools


Sidebar

tutorials:design_adv:using_language_template_set

This is an old revision of the document!


How to Import Language Template Set

These instructions will walk you through the steps needed to use any of the Language Translations provided in the public downloads on our site.

  1. Create a new language in the admin panel for the language you will be importing, if you have not already. You can do that in your admin panel on the page Languages > Add New Language, just type in the name of the language and click Save. This may take a while so be patient as it creates all of the text for this new language. <
  2. Download the language translation template set provided in the public downloads on our site to somewhere on your computer, and keep track of where you downloaded it to. You can find that section here. <
  3. In your admin panel, go to Design > Template Sets. Near the bottom of the page, click on the button to Upload Template Set. You should see a window similar to the one below: <
  4. Click the Browse button and browse to where you downloaded the language template set file to in step 2, and select the language template set file. Use the option to Rename uploaded set so that if you already have another template set with the same name, it will not over-ride that template set. <
  5. Click the Upload button. <
  6. When it is done uploading, you should see the new template set listed in the list of template sets. Click on the button Import Text Changes next to the uploaded template set. When you do, you will see a window that looks similar to below: <
  7. In the options for what language to import the changes to, select the language that you created back in step 1, then click Import Text. This step may take a while so be patient as it imports all the text for the language. <
  8. Once the import is complete, make sure the new template set is active by checking the active box next to the template set, if it is not already. <

<tip c n>Note: The template sets with translated text in them that are available on our site, only contain the templates that have translations in them, in other words the templates that have no changes from the default templates are not included with the template set. To get a "full" template set so that you can have all the templates in one place, you can use the Merge Sets Together button in your admin panel after you have followed the instructions above. What you would do, is make sure the translated template set is above yours in the list of template sets, then use that tool to merge the new template set with your main template set. If you do not yet have your main template set created, you can create one with the Create Main Template Set button near the bottom of the page.</tip>

Loading Template Set Based on Language

If you use a single language on your site, the instructions above are all you need to import and use the language based template set you need. If you have a multiple language website, and want to make it load a different template set for each language, you can do that by following the instructions below.

Skills

  • Comfortable with using FTP (to upload and download files from your site) <
  • Basic understanding of how PHP works will help, but not necessary if you have a forum account (to ask for help with the PHP portions in the forums ;-)). <

Instructions

  1. If you have not already, use the first set of instructions above to create each language and load the template set for that language on your website. <
  2. Turn off Geo cache, if currently turned on, in your admin at Site Setup > Cache. <
  3. In your admin, at Design > Template Sets, ensure that the template set(s) that you want to have active "by default" are used. You should have at least one template set that was created using the Create Main Template Set button on that page in the admin, one that was created based on the default templates that come with the software. <
  4. Download and open the file geo_templates/t_sets.php 1). The file will look something like this:
<?php
###########################################
## Auto-generated file
## It is not recommended to edit
## this file directly, but you can
## if you want.
## 
## Generated: Oct  5, 2010 17:07:16
###########################################

 
/**
 * To manually add your own template set, use the syntax:
 * 
 * geoTemplate::addTemplateSet('folder_name');
 * 
 * Where folder_name is the directory name, relative to this current directory.
 * NOTE: Default template set is always added by system as the last template set
 *  to load.  You do not need to add the default tempalte set here.
 * 
 * If you do not wish manual changes to be overwritten next time admin makes a
 * change, be sure to put them in the "custom section" below.
 */
 
if (!defined('IN_ADMIN')) {
# [CUSTOM SECTION] #
//Anything manually added to this section will be left intact even if changes
//are made in the admin panel.
 
//BOO!
 
# [/CUSTOM SECTION] #
}
 
geoTemplate::addTemplateSet('my_templates');

If you are still only using the default template set, that last line will be replaced by a PHP Comment stating that there are no template sets. If that is the case, that means you did not follow step 3 above correctly, follow that step and make sure you have your main template set active. <

  1. You will need to create a language ID map to map each language ID to the template set you want to load for that language ID. The language ID will be listed for each language in your admin at Languages > Languages Home. Once you figure out what template set you want to use for each language, you will need to create a snippet of PHP code, the syntax is as follows:
    $languages_map = array (
    24 => 'my_templates_french_5.1',
    25 => 'my_templates_arabic_5.1',
    );

In that example, it maps language ID 24 to the template set my_templates_french_5.1 and the language ID 25 to the template set my_templates_arabic_5.1. This is just an example, unless your site happens to match that mapping exactly, you will need to create one that matches for your site. If you need some help you may ask in the user forums for some help, just reference this tutorial and post what ID goes to what template set for your site. Someone should be able to help you create what you need. <

  1. Now, in the t_sets.php file, directly after the line # [CUSTOM SECTION] #, add the PHP you just created for the languages, followed by this:
    $session = geoSession::getInstance();
    $current_language = $session->getLanguage();
     
    if (isset($languages_map[$current_language])) {
    	geoTemplate::addTemplateSet($languages_map[$current_language]);
    }

<

  1. If your map happened to look like the example we gave, your t_sets.php file would now look like this:
    <?php
    ###########################################
    ## Auto-generated file
    ## It is not recommended to edit
    ## this file directly, but you can
    ## if you want.
    ## 
    ## Generated: Oct  5, 2010 17:07:16
    ###########################################
    
     
    /**
     * To manually add your own template set, use the syntax:
     * 
     * geoTemplate::addTemplateSet('folder_name');
     * 
     * Where folder_name is the directory name, relative to this current directory.
     * NOTE: Default template set is always added by system as the last template set
     *  to load.  You do not need to add the default tempalte set here.
     * 
     * If you do not wish manual changes to be overwritten next time admin makes a
     * change, be sure to put them in the "custom section" below.
     */
     
    if (!defined('IN_ADMIN')) {
    # [CUSTOM SECTION] #
    $languages_map = array (
    24 => 'my_templates_french_5.1',
    25 => 'my_templates_arabic_5.1',
    );
    $session = geoSession::getInstance();
    $current_language = $session->getLanguage();
     
    if (isset($languages_map[$current_language])) {
    	geoTemplate::addTemplateSet($languages_map[$current_language]);
    }
     
    //Anything manually added to this section will be left intact even if changes
    //are made in the admin panel.
     
    //BOO!
     
    # [/CUSTOM SECTION] #
    }
     
    geoTemplate::addTemplateSet('my_templates');

<

  1. Save the changes, and upload the file. <
  2. View the front page of your site. Does it still display correctly? If not, un-do the changes you made (especially if on a live site). If your site does display correctly, continue. <
  3. Change your language to each of the different languages you have on your site, and make sure the home page uses the correct template set for each language. If not, make sure you created that PHP map correctly in step 5 above, and then re-try. <
  4. You are done! Make sure you keep your site cache turned off, as it will cache the location of each file. When using a different template set for different languages, this will cause problems with the cache. <
1)
If you do not see that file on your site, in your admin at Design > Template Sets just click save and it will create the file.
tutorials/design_adv/using_language_template_set.1301424283.txt.gz · Last modified: 2014/09/25 16:55 (external edit)