Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Support for multilanguage sites, Internationalization (I18N)
(2013-04-10, 02:10:43)TeeJay Wrote: Hello everyone Smile

I have a website in Czech (cs) and English (en). However, I happened to meet a few major problems I could not solve.

1) When not using custom permalinks, default language is English -wrong. I need the default to be Czech. ...

If you don't encode the language in the URL, the language will default to the user's prefered language from his browser settings. If none of the languages matches, it will default to the default language (the pages without _xx in the slug).

(2013-04-10, 02:10:43)TeeJay Wrote: 2) When using these custom permalinks showing all the languages, to the admin panel I wrote

...

Everythings works as it is supposed be, except news from News Manager. You can see News Manager lines (starting with "clanky", "clanky" is my menu tam with news from News Manager), which are there for Fancy URLs (you can use Fancy URLs and News Manager without these lines in .htaccess). What should I add or change about the News Manager lines to make it work with this plugin and Fancy URLs?

Please ask this question in the News Manager thread. I don't know the News manager and its support for multiple languages.

(2013-04-10, 02:10:43)TeeJay Wrote: 3) When using custom permalinks showing only the secondary language, in the admin panel I wrote
Code:
%nondefaultlanguage%/%parent%/%slug%/
and changed .htaccess like this:
Code:
...

# To make custom permalinks with the secondary language only work :)
RewriteRule ^/?$ cs/ [R,L]   # optional
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(cs|en)/(.*?/)?([A-Za-z0-9-]+)/?$ index.php?id=$3&lang=$1 [QSA,L]
RewriteRule ^(cs|en)/?$ index.php?lang=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*?/)?([A-Za-z0-9-]+)/?$ index.php?id=$2&lang=en [QSA,L]

Looks fine.

(2013-04-10, 02:10:43)TeeJay Wrote: In this case, everything was wrong. On the title page, it was okay and Czech, correctly switchable into both languages back and forth. However, after clicking onto any menu tab or submenu tab, the language changed into English and couldn't be changed even with my language switching menu (which is:
Code:
<a class="en<?php if ($language == "en") echo "-current"; ?>" href="<?php echo htmlspecialchars(return_i18n_setlang_url('en')); ?>" title="English"></a>
          <a class="cz<?php if ($language == "cs") echo "-current"; ?>" href="<?php echo htmlspecialchars(return_i18n_setlang_url('cs')); ?>" title="Czech"></a>
What is funny about this menu - although the option of English is states first in the HTML code, it shows on the right side of its div. It's a CSS/HTML thing though.) The only menu tab where I can switch language is the index page, it just doesn't work anywhere else.

If you are using Chrome, you need to have a favicon.ico in your root directory (see first post in this thread).
Otherwise I can't tell without a link to your site.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
(2013-04-10, 04:47:21)mvlcek Wrote: If you don't encode the language in the URL, the language will default to the user's prefered language from his browser settings. If none of the languages matches, it will default to the default language (the pages without _xx in the slug).
Well, despite the fact that I'm Czech I use English Windows 7 and English Opera. Ok, thanks for the explanation. Maybe I'll try if it really works right on "Czech" computers.

(2013-04-10, 04:47:21)mvlcek Wrote: Please ask this question in the News Manager thread. I don't know the News manager and its support for multiple languages.
I will.

(2013-04-10, 04:47:21)mvlcek Wrote: Looks fine.

If you are using Chrome, you need to have a favicon.ico in your root directory (see first post in this thread).
Otherwise I can't tell without a link to your site.
I'm using Opera. I added the icon, I was about to put it there anyway. The site is under a password in a deep folder structure. To eliminate the chance that this would make it not work, I moved it onto a free hosting into root where my personal website was. I set up everything as it should be - as I mentioned as the point #3. Please, look at the site and its behaviour: http://tomas-janecek.php5.cz . Thanks for your time, I don't really know what's wrong. I think you won't have any problems differencing Czech from English, I don't think you understand Czech. Furthermore, you can see the flag of the current language highlighted in the top right corner. Don't look at the design, it's just a demo to make all the needed functions work. And yes, the FancyBox gallery stopped working, don't bother with it, it can be for some other reason.

To revise my setup:
The Base URL in the admin panel is
Code:
http://tomas-janecek.php5.cz/
Custom permalink structure in the admin panel is
Code:
%nondefaultlanguage%/%parent%/%slug%/

And this is my whole .htaccess
Code:
AddDefaultCharset UTF-8
Options -Indexes

# blocks direct access to the XML files - they hold all the data!
<Files ~ "\.xml$">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>
<Files sitemap.xml>
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

RewriteEngine on

# Usually RewriteBase is just '/', but
# replace it with your subdirectory path
RewriteBase /

# News Manager nastaveni:
RewriteRule ^clanky/tag/([^/.]+)/?$ index.php?id=clanky&tag=$1 [L]
RewriteRule ^clanky/post/([^/.]+)/?$ index.php?id=clanky&post=$1 [L]
RewriteRule ^clanky/page/([^/.]+)/?$ index.php?id=clanky&page=$1 [L]
RewriteRule ^clanky/archive/([^/.]+)/?$ index.php?id=clanky&archive=$1 [L]
# end News Manager


# To make custom permalinks with the secondary language only work :)
RewriteRule ^/?$ cs/ [R,L]   # optional
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(cs|en)/(.*?/)?([A-Za-z0-9-]+)/?$ index.php?id=$3&lang=$1 [QSA,L]
RewriteRule ^(cs|en)/?$ index.php?lang=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*?/)?([A-Za-z0-9-]+)/?$ index.php?id=$2&lang=en [QSA,L]

If needed, here is my plugin list (I tried to disable all I could - everything but I18N plugins, no difference)
FancyBoxPlugin, Innovation Theme Plugin, Send Anonymous Data, Czechoslovak Transliteration, I18N Base, I18N, News Manager, Create Post shortcut (News Manager), News Manager RSS, News Manager Title, p01-contact.

The problem is obvious - you visit the site, everything is Czech. You click onto any link (no matter if it's in the horizontal tab menu or vertical submenu) and the site switches to English (and yes, it will move onto the page you want, however, not in the desired language). You can't switch it to Czech if you're not on the index (title) page.

Thank you, I appreciate your will to help.
Tomáš Janeček - Multilingual personal website powered by GetSimple
» The little I did for GetSimple
Reply
Here is my reply to end this Smile
http://get-simple.info/forums/showthread...4#pid35334

Thank you for your effort. Smile Just look at the bottom part of my post in NM thread, the point 4) is still what I don't understand and the same problem mentioned above.

However, custom permalink structure of I18N is not a friend of News Manager. In link above there is a comment where I describe all reasonable options how to use both I18N and NM plugins.

Tom
Tomáš Janeček - Multilingual personal website powered by GetSimple
» The little I did for GetSimple
Reply
Hello once more,

a fast question only this time. Is there a way to make the last entry in the breadcrumbs a plain text instead of a hyperlink? It looks nicer and more logical to have the current site as a plain text.

This is my breadcrumbs code in the template
Code:
<p class="breadcrumbs" >
  <a href="<?php echo find_url('index',null); ?>">
    <?php if ($language == 'cs') { ?>Úvod<?php } ?>
    <?php if ($language == 'en') { ?>Home<?php } ?>
  </a>
    <?php get_i18n_breadcrumbs(return_page_slug()); ?>
    <?php nm_post_title('&raquo; '); ?>
</p>

Thanks for any ideas Smile
Tomáš Janeček - Multilingual personal website powered by GetSimple
» The little I did for GetSimple
Reply
(2013-04-10, 04:47:21)mvlcek Wrote:
(2013-04-10, 02:10:43)TeeJay Wrote: 3) When using custom permalinks showing only the secondary language, in the admin panel I wrote
Code:
%nondefaultlanguage%/%parent%/%slug%/
and changed .htaccess like this:
Code:
...

# To make custom permalinks with the secondary language only work :)
RewriteRule ^/?$ cs/ [R,L]   # optional
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(cs|en)/(.*?/)?([A-Za-z0-9-]+)/?$ index.php?id=$3&lang=$1 [QSA,L]
RewriteRule ^(cs|en)/?$ index.php?lang=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*?/)?([A-Za-z0-9-]+)/?$ index.php?id=$2&lang=en [QSA,L]

Looks fine.

Found the problem. It was the last line which is ending with "en", but it has to be ending with the standard language code which is "cs" for me.
It would be nice to emphasize this fact, it can be easily overlooked.


However I need some special rewrite rules for the News Manager now, because the posts of the NM don't seem to work in the second language with /en/ in the address. When there is nothing it works.

I have already asked in my topic about this problem.
http://get-simple.info/forums/showthread.php?tid=4659


What could be interesting for you maybe is that adding the second version of NM rewrite rules for the secondary langauge (English)
Code:
RewriteRule ^clanky/tag/([^/.]+)/?$ index.php?id=clanky&tag=$1 [L]
RewriteRule ^clanky/post/([^/.]+)/?$ index.php?id=clanky&post=$1 [L]
RewriteRule ^clanky/page/([^/.]+)/?$ index.php?id=clanky&page=$1 [L]
RewriteRule ^clanky/archive/([^/.]+)/?$ index.php?id=clanky&archive=$1 [L]

RewriteRule ^en/clanky/tag/([^/.]+)/?$ index.php?id=clanky&tag=$1 [L]
RewriteRule ^en/clanky/post/([^/.]+)/?$ index.php?id=clanky&post=$1 [L]
RewriteRule ^en/clanky/page/([^/.]+)/?$ index.php?id=clanky&page=$1 [L]
RewriteRule ^en/clanky/archive/([^/.]+)/?$ index.php?id=clanky&archive=$1 [L]
make it work but always after clicking onto a post it switches the language to English.

If you knew what to do, it would be nice. Thank you.
Tomáš Janeček - Multilingual personal website powered by GetSimple
» The little I did for GetSimple
Reply
Sad 
is there a way to solve the problem with %language% and %nondefaultlanguage% in sitemap?
I suppose there mvlcek did something cool, but it's not working for me Sad
-----------------------------------
UPD: its work fine, if we have more then 1 language. If it's only one lang, then we shouldn't add %language% and %nondefaultlanguage% in Custom Permalink Structure Setting.
Didn't know that
Reply
A suggestion:

If you need/want to use I18N (base) in a one-language site, it would be nice to be able to not display (or hide) this in the page manager:
Code:
If you want to add a new language, just create a page with a slug/URL ending with underscore and the language code (e.g. "index_de" for German).

Language of all pages with URLs without language code (like "index"), e.g. "de": [Save]

Maybe with a gsconfig setting?
Reply
I18N version 3.0.7:
  • dutch (thanks @Draxeiro) and french (thanks @alightweb) translations included
  • new setting in gsconfig.php for single language sites (@Carlos):
Code:
define('I18N_SINGLE_LANGUAGE', true);
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
A simple question, you can create a voice separator in the menu, forcing the slug with "#" does not work because is overwritten with default. Thanks
Reply
Maybe this is a known issue. With fancy urls disabled and no custom permalink structure, I get this in Settings (above User settings):
Quote:Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference lang=en in [...]\plugins\i18n_base\sitemap.class.php on line 54

Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference lang=es in [...]\plugins\i18n_base\sitemap.class.php on line 54
...

I imagine it's related to Sitemap generation. I've tried disabling it in gsconfig (GSNOSITEMAP, 3.2+) but I suppose I18N doesn't support that (yet).
Reply
I18N version 3.1:
  • fixes the sitemap generation with fancy URLs turned off and supports the constant GSNOSITEMAP (@Carlos)[/b]
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
hm, for some reason, this doesn't seem to work for me...
I have pages created in german and now created a "news_en.xml" version of my "news.xml"... but I can't get to view this. Even when I type /news/?lang=en in the browser, it still shows me the german version (same as lang=de)... same with /de/news and /en/news ... any ideas what the problem might be? Did I forget something? I'm using i18n_header and i18n_navigation already Sad
Reply
(2013-05-03, 20:28:11)Kida Wrote: hm, for some reason, this doesn't seem to work for me...
I have pages created in german and now created a "news_en.xml" version of my "news.xml"... but I can't get to view this. Even when I type /news/?lang=en in the browser, it still shows me the german version (same as lang=de)... same with /de/news and /en/news ... any ideas what the problem might be? Did I forget something? I'm using i18n_header and i18n_navigation already Sad

Did you set the default language (on pages view in adminstration) correctly to "de"?
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
Hi mvlcek,

I building a new site and as usual am I using your plugin. But this time I got these errors:

Warning: copy(/home/dan28884/public_html/2013/plugins/i18n_common/loadext.php) [function.copy]: failed to open stream: No such file or directory in /home/dan28884/public_html/2013/plugins/i18n_common/common.php on line 62

Warning: Cannot modify header information - headers already sent by (output started at /home/dan28884/public_html/2013/plugins/i18n_common/common.php:62) in /home/dan28884/public_html/2013/admin/inc/cookie_functions.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /home/dan28884/public_html/2013/plugins/i18n_common/common.php:62) in /home/dan28884/public_html/2013/admin/inc/cookie_functions.php on line 24

I am using the latest version of GS and of your plugin. Have you any idea what went wrong..?
The site in questtion: www.egotag.dk/2013

Best regards,
Lasse
Reply
(2013-05-03, 20:52:15)mvlcek Wrote:
(2013-05-03, 20:28:11)Kida Wrote: hm, for some reason, this doesn't seem to work for me...
I have pages created in german and now created a "news_en.xml" version of my "news.xml"... but I can't get to view this. Even when I type /news/?lang=en in the browser, it still shows me the german version (same as lang=de)... same with /de/news and /en/news ... any ideas what the problem might be? Did I forget something? I'm using i18n_header and i18n_navigation already Sad

Did you set the default language (on pages view in adminstration) correctly to "de"?
I did... but only after I created all pages. Before it was set to "en"... is that a problem? After I set it to "de" I created a completely new page as test with it's english twin, and it didn't work either...
Reply
(2013-05-03, 21:26:17)graphiclunch Wrote: Hi mvlcek,

I building a new site and as usual am I using your plugin. But this time I got these errors:

Warning: copy(/home/dan28884/public_html/2013/plugins/i18n_common/loadext.php) [function.copy]: failed to open stream: No such file or directory in /home/dan28884/public_html/2013/plugins/i18n_common/common.php on line 62

Warning: Cannot modify header information - headers already sent by (output started at /home/dan28884/public_html/2013/plugins/i18n_common/common.php:62) in /home/dan28884/public_html/2013/admin/inc/cookie_functions.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /home/dan28884/public_html/2013/plugins/i18n_common/common.php:62) in /home/dan28884/public_html/2013/admin/inc/cookie_functions.php on line 24

I am using the latest version of GS and of your plugin. Have you any idea what went wrong..?
The site in questtion: www.egotag.dk/2013

Best regards,
Lasse

I have the same problem. Can anybody help ?
Thanks.
Reply
I figured out where my problem is... instead of get_page_content I use (and have to use) returnPageContent('slug')... and as the slug for both versions is news (intead of "news" and "news_en") I always get the german (news) version.

I know a quick fix is adding _en if the get-parameter lang is set to en, but that's not really nice... also because I guess there is a cookie set after the language was switched, right?

Therefore it's be better to work with the right slug (including the _en) all along... get_page_slug() returns it without the ending sadly Sad Is there a way to get the slug WITH the language end??
Reply
(2013-05-05, 02:33:51)Kida Wrote: I figured out where my problem is... instead of get_page_content I use (and have to use) returnPageContent('slug')... and as the slug for both versions is news (intead of "news" and "news_en") I always get the german (news) version.

...

Why don't you use I18N's get_i18n_content(slug_without_lang)?
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
because I need a function, that returns the content to me and not prints it out directly Sad
I guess, I'll have to try writing my own return_i18n_content or sth...

... okay, done. that was quite simple actually Big Grin Big Grin now I have a return_i18n_content Wink
Reply
I found an odd behaviour of find_i18n_url function in GS 3.2.1 with furls enabled.
Example code I use:
Code:
find_i18n_url('samplepage',$language);
outputted link on non default language pages contains doubled lang in url, so it looks like:
Code:
http://website/en/en/samplepage
Website works, as GS along with i18n rewrite rules do not cover nested pages below 2nd level.

Looking at a backup based on GS 3.2 same problem occur.
Tried with i18n 3.05 and latest 3.1.
Might it be a problem with custom rewrite rules ?

I've got also two more questions:
1. Is there also a way of getting rid of getting a link containing default language switch in this function ? Because links will be duplicated when using custom url structure with %nondefaultlanguage% ...

2. I wanted to get a standalone link to parent (in respective language), and show it on all its slugs.
Is there maybe a builtin' function for this, rather than using below sample code ?
Code:
$bc = return_i18n_breadcrumbs(return_page_slug());
echo '<a href="'.find_i18n_url($bc[0]['url'],$language)">'.$bc[0]['menu'].'</a></li>';
Addons: blue business theme, Online Visitors, Notepad
Reply
(2013-05-05, 03:11:15)Kida Wrote: because I need a function, that returns the content to me and not prints it out directly Sad
I guess, I'll have to try writing my own return_i18n_content or sth...

... okay, done. that was quite simple actually Big Grin Big Grin now I have a return_i18n_content Wink

You can use the following to return the pages's XML and get the content using a $slug without language:
Code:
$xml = I18nFrontend::getPageData($slug);
$content = stripslashes(htmlspecialchars_decode($xml->content, ENT_QUOTES));

(2013-05-05, 12:12:16)yojoe Wrote:
Code:
find_i18n_url('samplepage',$language);

The second parameter should be the parent or null. In your case it outputs the current language and the parent (both 'en').

(2013-05-05, 12:12:16)yojoe Wrote: 2. I wanted to get a standalone link to parent (in respective language), and show it on all its slugs.
Is there maybe a builtin' function for this, rather than using below sample code ?
Code:
$bc = return_i18n_breadcrumbs(return_page_slug());
echo '<a href="'.find_i18n_url($bc[0]['url'],$language)">'.$bc[0]['menu'].'</a></li>';

Your code gives a link to top-most ancestor (if you are on third level or below) - and the second parameter to find_i18n_url is wrong again. In general you don't need to specify the language, if it should not change.

To get a link to the parent, you can also use
Code:
get_i18n_link(get_parent(false));
If you use fancy urls, use the newest plugin version 3.1.1.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
(2013-05-05, 15:37:16)mvlcek Wrote: The second parameter should be the parent or null. In your case it outputs the current language and the parent (both 'en').

Ohhh gracias, that explains all the problems I experienced.
Without 2nd parameter I was getting warning with missing argument 2, and I assumed it cannot be just ... NULL. It's not always possible to know the parent when pages are being moved.
(disabling error reporting with @ prefix is - you know ... not the way of fixing anything)

(2013-05-05, 12:12:16)yojoe Wrote: 2. I wanted to get a standalone link to parent (in respective language), and show it on all its slugs.
Is there maybe a builtin' function for this, rather than using below sample code ?

[quote='mvlcek' pid='36135' dateline='1367732236']
Your code gives a link to top-most ancestor (if you are on third level or below) - and the second parameter to find_i18n_url is wrong again. In general you don't need to specify the language, if it should not change.
Yes, the code was supposed to always show top parent in a tree of nested pages, regardless of currently visited slug, and also while visiting the parent page.
get_i18n_link only shows parent of current slug if the slug has any.

(2013-05-05, 15:37:16)mvlcek Wrote: If you use fancy urls, use the newest plugin version 3.1.1.

Updated, everything works fine.
Thanks again Smile
Addons: blue business theme, Online Visitors, Notepad
Reply
I18N version 3.2:
  • supports a new placeholder in fancy URLs: %parents% to output parent, grandparent, etc. (@Kida, @bandrzej and others)
  • finally supports all placeholders also when selecting a page link in the editor
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
I just had an orgasm
Reply
(2013-05-06, 03:21:19)mvlcek Wrote: I18N version 3.2:
  • supports a new placeholder in fancy URLs: %parents% to output parent, grandparent, etc. (@Kida, @bandrzej and others)
  • finally supports all placeholders also when selecting a page link in the editor

Just gave it a test run on a site in development (which is still using GS 3.2.0, haven't updated yet to 3.2.1.) but when selecting an link to a local page in the editor %language% or %nondefaultlanguage% (depending on which of the two solutions is used) is still shown in the link instead of the language code (say 'en' or 'de').

Or was I wrongly assuming the 'supports all placeholders also when selecting a page link in the editor' is a solution for the previously brought up and replied upon point by yojoe (around august last year)?

See quote below:

(2012-08-24, 17:22:59)mvlcek Wrote:
yojoe Wrote:While using i18n v3.0.2 with custom link structure %language%/%parent%/%slug% every time I try to insert a link I get a %language% inside the url, which isn't being parsed into language abbeviation.
One of example links from a demo page of mine theme looks like this:
Quote:<a href="http://getsimple.wujitsu.pl/bluebusiness/%language%/news/">news</a>
and I have to change %language% manually.

Is this caused by specific GS config (what additional info should I provide ?), or did somebody encounter similar behaviour ?

I suppose something needs to be changed for the CKEditor page selection. I'll add it to my to-do list...

Basically what I've done is use the %language%/%parent%/%slug%/ custom url structure, update the .htaccess file as per the instructions on mvlcek's great documentation site and now updated the plugin to 3.2. So I think I did everything correctly.
Reply




Users browsing this thread: 10 Guest(s)