The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 916 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
COMPLETE Theme I18N (HERE'S THE CODE)
#1
I would need one thing to get along with GetSimple: theme localization.

You can check out a working example of how I did it: http://http:getsimple.mechantdesign.com/

Look at how I've worked it out:

1) Define localization variable in gsconfig.php:

Code:
define('GSTHEMEI18N', 'true');

/* Expected urls have now the following form: http://example.com/fr_FR/ */


**********


2) Changing the .htaccess rewrite rule to:

Code:
RewriteRule ^(.*)$ index.php?id=$1 [QSA,L]

/* This will send the whole query string to index.php. This can be helpful for many other things too. */


**********


3) Do a little bit more parsing in index.php:

Code:
if (isset($_GET['id'])) {
$PAGE_REQUEST = $_GET['id'];
if (substr($PAGE_REQUEST, -1) == '/') {
$PAGE_REQUEST = rtrim($PAGE_REQUEST, '/');
}
$PAGE_REQUEST = explode('/', $PAGE_REQUEST, 3);
} else {
$id = "index"; //btw, why here you use double quote here ?
}

/* We now have a very informative array that we'll break down differently depending on if the the theme I18L is true */

Code:
if (GSTHEMEI18N) {
if (count($PAGE_REQUEST) == 1) {
$LANG = $PAGE_REQUEST[0];
$id = 'index';
} if (count($PAGE_REQUEST) > 1) {
$LANG = $PAGE_REQUEST[0];
$id = end($PAGE_REQUEST);
} else {
$id = 'index';
}
}

/* Another function should be use to associate .../fr/ to .../fr_FR/ */

Code:
# define page, spit out 404 if it doesn't exist
$file = GSDATAPAGESPATH . $LANG . '/' . $id .'.xml';

...


**********


4) Create a language hierarchy in the data/pages folder, so that we would have both of these pages:

en_US/i-love-get-simple.xml & fr_FR/i-love-get-simple.xml


**********


5) Modify the "get_navigation" function in admin/inc/theme_functions.php to change "$path":

/* At the very top of the function... */

Code:
//right here
if (GSTHEMEI18N) {
global $LANG;
$path = GSDATAPAGESPATH . $LANG . '/';
}
//done

$dir_handle =...

...


**********


6) Modify the "find_url" function in admin/inc/basic.php to change output:

/* At the top of the function... */

Code:
if ($type == 'full') {
$full = $SITEURL;

//right here
if (GSTHEMEI18N) {
global $LANG;
if (!isset($link_lang)) $link_lang = $LANG;
$full .= $link_lang . '/';
}
//done

} elseif($type == 'relative') {

...


**********


6) Create a special function, ressembling the "find_url" function in admin/inc/basic.php to change output the same page in other languages:

Code:
function find_local_current_url($link_lang) {
global $SITEURL;
$full = $SITEURL;
$slug = get_page_slug(false);
if ($slug != '') $slug .= '/';
$parent = get_parent(false);
if ($parent != '') $parent .= '/';
if (GSTHEMEI18N) {
global $LANG;
if (!isset($link_lang)) $link_lang = $LANG;
$full .= $link_lang . '/';
}
$full .= $parent . $slug;
return $full;
}

/* This function is a quick fix... a lot needs to be done to make it more versatile */


****************************************


ON THE SIDE:

I would also suggest to redirect url without trailing slashe to a with-slash url using the following .htaccess rule, as some search engine may consider these 2 pages as distinct (yet identical) and mark them as duplicated content.

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L,R=301]


****************************************


Please let me know what you think of the code! I haven't check for all the admin stuff, but I don't think it will be very complicated. It's really all I need to choose GetSimple as my CMS for my next project Smile

Please, I need feedback!

Thank you!
Reply


Messages In This Thread
COMPLETE Theme I18N (HERE'S THE CODE) - by lacroixca - 2011-12-04, 13:58:18
COMPLETE Theme I18N (HERE'S THE CODE) - by mvlcek - 2011-12-06, 00:11:36



Users browsing this thread: 1 Guest(s)