How I made multilanguage Frog sites with page parts
|
24 posts
|
I found using page parts are the most end user friendly way to have multi-language content and found a way to make them work.
First create a snippet called “check_locale”
I included a number of languages as a default, but you can add whichever ones you want. Language codes are available here Next include this snippet above your normal layout like so
I then also edited my layout to display the specific language, should the session var and the page part exist. First, I commented out of the following:
And added the following:
This checks for the session variable and displays the page part should it exist, if it doesn’t it shows the default content (body). I then created a hidden page called lang, with layout set to none with the following code:
You can link to this page with something similar to this:
It will automatically forward you back to the page in which you clicked it from, displaying your new language. NOTES This does not solve the search engine issues, which I am totally open to suggestion for to allow Google to index the other language pages. Please post fixes/bugs or suggestions here and I will update this post. |
|
1493 posts
|
Nice solution, defunct! This looks like it could be very useful. I can spot two limitations (other than the Google thing), which do not detract from the usefulness of this solution “as-is”, but may be worth noting:
Meanwhile, thanks for the write-up! Looks good! |
|
257 posts
|
I think that the cookie option is a viable option in the short term, but long term maybe not |
|
24 posts
|
@David I’m glad you pointed that out…I never even considered it. Must be some work around for it, I’ll think about it. Now I know why a lot of people are using pages to do this. |
|
651 posts
|
@defunct – The snippet that checks for the browser’s preferred language is quite nice. It can be improved upon a bit and I would probably turn it into a Plugin (“Language Redirect” aka “lang_redir” anyone?). The plugin could then probably use the Observer system and the “page_requested” event to do some clever stuff like redirecting, etc… Just a suggestion though. :-) |
|
1493 posts
|
A suggestion about NOT using the “extended” page-part for “Read more…” links is here. I’m not sure how the thought below fits in with Martijn’s musings, but would this pictured suggestion be a Froggish way of accomplishing what this Wordpress plugin does?
|
|
41 posts
|
A solution for the multilingual titles (just thinking out loud), could be using a similar approach of David’s suggestion of the read more without page parts. You can create a page part called “titles”, enclose the titles with tags for each language (<de>Title</de>, etc or something similar), and in the Layout, modify:
With some function (sorry, I’m too bad on php) who reads the ‘titles’ page part. Mmmhh… I’ll take a look to that to see if I can write something that works. |
|
651 posts
|
Hmmmm… this is beginning to become increasingly more complex… For now, I will (personally) stick with using the copy-tree functionality to create a language specific subtree. Though I will be using defuncts function to auto-redirect the user to a new subtree based on the browser’s preferred language. |
|
1493 posts
|
@Pnikosis – I’m aiming for another beer… :P IF you want to use defunct’s technique, and IF you want to have language-specific titles, you COULD do it this way: - add another page-part called ‘titles’, and for each language page-part you have, add in the appropriate title this way: UPDATE : the solution originally posted here wasn’t reliable. Go down a few posts to find Craig’s working code. |
|
41 posts
|
@David – You definitively won it, beware of your liver because at this pace I will have to invite you a full beer keg :P |
|
1493 posts
|
Don’t roll out the barrels too quickly, Pnikosis! On further testing, I don’t think that “titles” solution is working quite right. =/ Will report back…. |
|
76 posts
|
Just a thought on David’s title posting… Regular expressions might be quicker, and if in this sort of format too: |
|
1493 posts
|
@craig – are you around IRC just at the moment…? |
|
1493 posts
|
Right — solution from IRC. Craig cracked it! (That’ll be a pint for my friend, then! :P ) Use the page-part “titles”, with filter set to
That is, with your language-specific title following their 2-character tag. Then, in your Layout where you expect the page title to come (the
And … it works! I’ll see about setting up a live example.* Craig says: “people can then turn it into a snippet if they like to keep it out of the layout” [from IRC]. And he’s quite right. I just dumped all that into a
and all is as it should be! It certainly makes for a tidier layout. Thanks, Craig! And thanks again, defunct, for setting this one rolling.
|
|
76 posts
|
You’re welcome, happy to help out. |
|
41 posts
|
Fantastic. This will end in some kind of beerfest. |
|
1493 posts
|
If anyone wants to see the defunct + Craig/David multilingual solution at work, have a look at this page (as long as it lasts: it’s a temporary test install), and use the language links in the footer to change the page. There are, of course, some limitations to this technique, but I fully agree with Pnikosis! I would be interested to know if anyone looks at the page whose browser locale is set to one of: |
|
24 posts
|
We need one final thing…displaying a translated menu. I set my default language to German and it shows the German text by default. |
|
24 posts
|
@Martijn Oh yeah feel free to make/release a plugin for the language redirect :) |
|
1493 posts
|
:) P.s. The menu code! It’s just a mash-up of Craig’s routine with the MadeByFrog style sidbar menu The
|
|
40 posts
|
I don’t know if I’m being rude, if you could make the above site avaible for download so people can have a look on how this exactly works. Me as a non back-end coder, finds this topic chaotic to read:D thanks in advance! (and sorry if this is an insult to you…) |
|
1493 posts
|
Neither rude, nor insulting! It would be good to have this as an easier-to-follow tutorial. Consider it on the “to-do” list. Where’s that wiki again…? :P |
|
17 posts
|
Wow since my last post with picture from WP plug-in, this is the best solution I ever seeing here! All my studio sites where I now working are based on ModX and copy-tree functionality to create a language specific subtree. And i can say that that technique is terrible! Imagine, 300 documents in English, than you copy that tree, than you translate it, than you copy it again… When the How-to will be available? ;) |
|
2 posts
|
Hey there! I got an issue with the hidden “lang” page. I’ve taken all the code from first post and followed the instructions. If I overstep the “lang” page and set the lang parameter myself it works fine. Did I forget something? Greetings, |
|
1 posts
|
I’m new with frog and download the version 0.9.5. I try to solve my issue with the multilangue support but i got stuck with the link to change view lang. When i use the code you provide : I got an error saying page not found If i remove the lang/ from the url, the lang of my site change but i’m alway redirect to the home page and it’s not what i want. Thanks for help |

