Skip to main content

Warning: count(): Parameter must be an array or an object that implements Countable in C:\home\site\wwwroot\gs\plugins\i18n_navigation\frontend.class.php on line 219

GetSimple

HOW TO: I18N Plugin + Fancy URLs + Lighttpd + Multilingual

I installed I18N plugin v2.5.6 on a clean installation of GetSimple 3.0 on top of lighttpd. I enabled mod_rewrite and enabled the 10-getsimple.conf.

Instructions

For a language selector on top of every page

OPEN theme/theme-name/header.php

ADD inside wrapper div

                <!-- language selection -->
                <nav id="lang-nav" style="top:2px;">
                    <ul>
                    <?php foreach(return_i18n_available_languages() as $i => $lang){
                        echo '<li'.(($lang == $_GET['lang']) ? ' class="current"' : '').'>'
                            ."\t".'<a href="'.htmlspecialchars(return_i18n_setlang_url($lang)).'">'.$lang.'</a>'
                            .'</li>';
                    }?>
                    </ul>
                </nav>

To fix Home link of breadcrumbs

FIND

                <a href="<?php get_site_url(); ?>">Home</a> &nbsp;&nbsp;&#149;&nbsp;&nbsp; <?php Innovation_Parent_Link(get_parent(FALSE)); ?> <b><?php get_page_clean_title(); ?></b>

REPLACE WITH

                <?php
                    // Fetch menu title for index page
                    $tmp = return_i18n_menu_data('index');
                    $tmp = $tmp[0]['menu'];
                    echo '<a href="'.find_i18n_url('index').'">'.$tmp.'</a>';

                    //Fetch rest breadcrumbs
                    get_i18n_breadcrumbs(return_page_slug());
                ?>

Enabling Fancy URL at server level

Enable mod_rewrite in lighttpd.conf and enable the usage of the following conf.

10-getsimple.conf

$HTTP["host"] =~ "(^|www\.)example\.com$" {

    # Deny access to the backups, data and plugins directories...
    $HTTP["url"] =~ "^/gs/(backups|data|plugins)/" {
        # ...except the uploads, thumbs and every css, js, or images directory inside plugins
        $HTTP["url"] !~ "^/gs/(data/(uploads|thumbs)|plugins/(.*?/)(css|js|images))/?" {
            url.access-deny = ("")
        }
    }

    # Disable directory listing
    $HTTP["url"] =~ "^/gs($|/)" {
        dir-listing.activate = "disable"
    }


    # Use mod_rewrite for fancy URLS
    url.rewrite-if-not-file = (
        "^/gs/(en|gr)/(.*?/)?([A-Za-z0-9_-]+)/?$" => "/gs/index.php?id=$3&lang=$1",
        "^/gs/(en|gr)/?$" => "/gs/index.php?lang=$1",
    )


    $HTTP["url"] =~ "^/gs/?$" {
        url.redirect = (
            # Optional
            "/" => "http://www.example.com/gs/en/"
        )
    }
}

Notes

  1. If your GetSimple installation directory is / instead of /gs/ that I used in this example, simply search and replace all instances of /gs (without trailing slash).
  2. In this example I have only used, two languages, English and Greek. You can add as many as you want, as long as you make the appropriate changes to 10-getsimple.conf or if you replaced (en|gr) with ([a-z]{2}).