The following warnings occurred:
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
/printthread.php 203 postParser->parse_message
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
/printthread.php 203 postParser->parse_message
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
/printthread.php 203 postParser->parse_message
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
/printthread.php 203 postParser->parse_message



GetSimple Support Forum
COMPLETE Theme I18N (HERE'S THE CODE) - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Developer Discussions (http://get-simple.info/forums/forumdisplay.php?fid=8)
+--- Thread: COMPLETE Theme I18N (HERE'S THE CODE) (/showthread.php?tid=2460)



COMPLETE Theme I18N (HERE'S THE CODE) - lacroixca - 2011-12-04

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!


COMPLETE Theme I18N (HERE'S THE CODE) - ccagle8 - 2011-12-05

I feel like this would be a great addition if we ever add mvcek's plugin to the core... This would be a great starting point to add it in. Thanks for the tutorial... i'm sure it will help many people here!


COMPLETE Theme I18N (HERE'S THE CODE) - lacroixca - 2011-12-05

Hi Chris,
Thanks for the reply !
Can you tell me what exactly do you refer to when you write mvcek's plugin?


COMPLETE Theme I18N (HERE'S THE CODE) - mvlcek - 2011-12-06

lacroixca Wrote:Hi Chris,
Thanks for the reply !
Can you tell me what exactly do you refer to when you write mvcek's plugin?

The I18N plugin does all this and more without patching the GetSimple core.