I have a question regarding permalinks and rewriting url's. I am writing a translation plugin and I would like to add the language shortcode in my url (Something like http://eyewebz.com/EN/other_permalinks). Currently I am assigning a $_Session-variable to hold the current selected language, but this isn't really visible for the users.
I am able to rewrite the url with the below code, but after altering the url, the page doesn't show any content and the global $post-variable is completely empty. Code is below.
function alter_link_language($permalink)
{
$active_language = get_user_selected_language();
$current_language_shortcode = strtoupper( $active_language["shortname"] );
$permalink = str_replace(get_bloginfo('home'), '', $permalink);
return get_bloginfo('home') . '/' . $current_language_shortcode . $permalink;
}
add_filter('post_link', 'alter_link_language', 10);
add_filter('page_link', 'alter_link_language', 10);
If anyone could help me on wy way with this one, it would be greatly appreciated!
thanks in advance!