2012-02-05, 09:34:15
I installed I18N plugin v2.5.1 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
FIND
REPLACE WITH
OPEN plugins/i18n_base/frontend.class.php
FIND
AFTER, ADD
FIND inside function getFancyLanguageUrl
REPLACE WITH
OPEN admin/edit.php
FIND
REPLACE WITH
Finally, enable mod_rewrite in lighttpd.conf and enable the usage of the following conf.
10-getsimple.conf
NOTE: 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)
NOTE 2: In this example I have only used, two languages, English and Greek. You can add as many as you want, as long as their identifier is 2 characters long and you make the appropriate changes to theme/theme-name/header.php and 10-getsimple.conf.
Have fun!!
Instructions
For a language selector on top of every page
OPEN theme/theme-name/header.php
ADD inside wrapper div
Code:
<!-- language selection -->
<div class="language-selector">
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url('gr')); ?>">Greek</a> | <a href="<?php echo htmlspecialchars(return_i18n_setlang_url('en')); ?>">English</a><br/>
</div>
FIND
Code:
echo find_url('index',null);
Code:
echo (function_exists('find_i18n_url') ? find_i18n_url('index',null) : find_url('index',null));
OPEN plugins/i18n_base/frontend.class.php
FIND
Code:
public static function getURL($slug, $slugparent, $language=null, $type='full') {
global $url, $parent, $PERMALINK, $PERMALINK_ORIG;
Code:
$PERMALINK_ORIG = isset($PERMALINK_ORIG) ? $PERMALINK_ORIG : $PERMALINK;
FIND inside function getFancyLanguageUrl
Code:
global $SITEURL, $PERMALINK_ORIG, $language;
Code:
global $SITEURL, $PERMALINK, $PERMALINK_ORIG, $language;
$PERMALINK_ORIG = isset($PERMALINK_ORIG) ? $PERMALINK_ORIG : $PERMALINK;
OPEN admin/edit.php
FIND
Code:
echo '<a href="', find_url($url, $parent) ,'" target="_blank" accesskey="', find_accesskey(i18n_r('VIEW')), '" >', i18n_r('VIEW'), ' </a>';
Code:
if(strpos($url, '_') !== false){
$language = explode('_', $url);
$language = $language[count($language)-1];
if(strlen($language) == 2){
$url2 = substr($url, 0, -3);
}
}
$language = ($language) ? $language : return_i18n_default_language();
echo '<a href="', (function_exists('find_i18n_url') ? find_i18n_url($url2, $parent, $language) : find_url($url2, $parent)) ,'" target="_blank" accesskey="', find_accesskey(i18n_r('VIEW')), '" >', i18n_r('VIEW'), ' </a>';
Finally, enable mod_rewrite in lighttpd.conf and enable the usage of the following conf.
10-getsimple.conf
Code:
$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/"
)
}
}
NOTE: 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)
NOTE 2: In this example I have only used, two languages, English and Greek. You can add as many as you want, as long as their identifier is 2 characters long and you make the appropriate changes to theme/theme-name/header.php and 10-getsimple.conf.
Have fun!!