Topic: [Tutorial] Multilingual Websites with MODx (improved version)  (Read 29143 times)

Pages: 1 2 [3] 4   Go Down

#41: 19-May-2009, 06:53 AM

Coding Team

sottwell
Posts: 10,540

WWW
Chunks are simply er... chunks of plain text or HTML, and are inserted as-is into a document being processed. If there are any MODx tags in the chunk content, they will be processed during the next pass through the parser (a maximum of 10 passes in all). They are often used for basic content, such as footer or header content, that will be used on all pages, even if the pages use different main templates. This way you only have to change the address or phone number in your page footers, for example, in the chunk, and the change will work across all pages no matter what template they use.

Chunks are also useful if you need to have a very long, complex snippet call with lots of parameters, and need to use the rich text editor on the document. The rich text editor can "helpfully" totally trash the snippet call's parameter list. So putting the snippet call in a chunk, then using the chunk tags in the document content will protect the snippet call.

http://sottwell.com/how-templates-work.html

Wayfinder, Ditto and a number of other snippets are coded to use given chunks as mini-templates for the various parts of their output. Usually these mini-template chunks will contain HTML code and [+ ... +] placeholders, which are taken from an array that MODx uses to store output or other values that snippets can produce for later use.

« Last Edit: 19-May-2009, 06:57 AM by sottwell »
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html

#42: 26-May-2009, 06:34 AM

x0149128
Posts: 411

What if you don't use SEO friendly urls (or more correctly is your server doesn't fully support it)?

How does this actually work?

Would I produce my site as:

Root
--EN
----Home
----Products
--DE
----Home
----Products
--NL
----Home
----Products

What would happen is say English and Dutch held some different content e.g the English section has a news page but he other countries do not?

i'd want English to be the default site, with links at the bottom of the home page to change the language.

If you are using CSS sprites for the menu, how does this automatically change the menu image?
« Last Edit: 26-May-2009, 06:37 AM by c-m »

#43: 26-May-2009, 07:54 AM


therebechips
Posts: 386

WWW
@c-m

using separate document roots for each language would risk running into the approximate 5000 document limit - with 30 odd languages you could approach this quickly. The other approach is to use TVs (you'd need at minimum 60+ for your template - pagetitle + content ), but this is also more than the optimal 20 or so TVs before things start to slow down (so I'm told - I've never used more than this); however, this might be your best approach providing the output of your page is cached after the first view (this bit is critical). There is a snippet/module/plugin in development that will do this:

http://modxcms.com/forums/index.php/topic,35940.msg217368.html#msg217368

The better alternative however might be to use Revo which introduces a new concept called Contexts for exactly this type of problem.



Snippets: GoogleMap | FileDetails | Related Plugin: SSL

#44: 26-May-2009, 08:00 AM

x0149128
Posts: 411

At the moment I only have translations for about 4 languages that will be 30 pages each.

The other languages will come in but his will probably be over a year and a half before i have all them. By that time Modx 3.0 might be in beta  Wink


I'm happy to give this method a go with a couple of languages, it beats the alternative that was to have each language as seperate modx install  Shocked

What exactly does this part mean in the opeing post:

Quote
Enter a languageIdentifier for every page. It could be the same as your alias for example.

does that mean for each page i should set the alias to something like product-nl, home-nl, home-de etc....?


Code:
Create a new template variable with name "languageIdentifier"
What goes in this TV is it rawtext, richtext etc.. where is it called?

I'd love to see a working example
« Last Edit: 26-May-2009, 08:22 AM by c-m »

#45: 26-May-2009, 08:29 AM


elz64
Posts: 427

WWW
Hi Susan,


Can you tell me if this context stuff would be something like a virtual root ?

is this close to some Directory concept (like Novell eDIR for instance with the CX container ?)

Thank you
Schtroumpf Grognon - Grouchy Smurf
---------------------------------
Faites pas attention.. - Don't pay attention

#46: 27-May-2009, 09:05 AM

x0149128
Posts: 411

Ok this works fine - wohoo.

My problem is that for each language I have a different CSS image sprite for the menu.

Is the only way to have the menu show correctly to create a template for each seperate language?

#47: 27-May-2009, 10:30 AM


elz64
Posts: 427

WWW
hi c-m


I suggest you have a look to PHX, wich is the only (afaik) way to intriduce some logic into modx template without snippet.
here : http://wiki.modxcms.com/index.php/PHx#Snippets_supporting_PHx

some basic example:
Code:
[+phx:if=`[+this+]`:is=`[+that+]`:then=`do this`:else=`do that`+]

you can test [+Language+] to determin what chunck to fire.
Schtroumpf Grognon - Grouchy Smurf
---------------------------------
Faites pas attention.. - Don't pay attention

#48: 27-May-2009, 11:28 AM

x0149128
Posts: 411

Thanks, as a non programmer who only understands copy paste copy paste, I think i'll just go for different templates for the time being. I will look into this was more of the languages get translated.

#49: 28-May-2009, 05:09 AM

x0149128
Posts: 411

I have all the flags in a list horizontally across the bottom of my index page.

However how do I hide the text next to the flags?

#50: 28-May-2009, 07:54 AM


elz64
Posts: 427

WWW
hhh..
You should have some html skill isnt'it ? just look at the img tag

This a question of css or you can modify the template chunck use for this 'flag menu' and delete the text from the <a> tag

Code:
<li class="[+wf.classnames+]">&nbsp;<a href="[[link_to_language?id=`[+wf.docid+]`&link=`[+wf.link+]`&actualid=`[*id*]`]]" title="[+wf.description+]"><img src="[(base_url)]assets/images/flags/[+wf.linktext+].gif" alt="[+wf.linktext+]"  />&nbsp;[+wf.title+]</a></li>

see ?  here :
.....<img src="[(base_url)]assets/images/flags/[+wf.linktext+].gif" alt="[+wf.linktext+]"  />&nbsp;[+wf.title+]</a>
Schtroumpf Grognon - Grouchy Smurf
---------------------------------
Faites pas attention.. - Don't pay attention

#51: 28-May-2009, 10:07 AM

x0149128
Posts: 411

hhh..
You should have some html skill isnt'it ? just look at the img tag

This a question of css or you can modify the template chunck use for this 'flag menu' and delete the text from the <a> tag

Code:
<li class="[+wf.classnames+]">&nbsp;<a href="[[link_to_language?id=`[+wf.docid+]`&link=`[+wf.link+]`&actualid=`[*id*]`]]" title="[+wf.description+]"><img src="[(base_url)]assets/images/flags/[+wf.linktext+].gif" alt="[+wf.linktext+]"  />&nbsp;[+wf.title+]</a></li>

see ?  here :
.....<img src="[(base_url)]assets/images/flags/[+wf.linktext+].gif" alt="[+wf.linktext+]"  />&nbsp;[+wf.title+]</a>

Thanks - I just blindly copied and pasted the original code without really thinking about it. I had tired to style them and use text-indent: -999px; but that didnt work.

You solution well.

Thank you.

#52: 10-Jul-2009, 04:53 AM

x0149128
Posts: 411

Everything has worked well so far, but I have now been asked to add the name of the language, when the user hovers over the flags. With a simple list and images this is easy but how do i do it with this solution?

Thanks

#53: 10-Jul-2009, 10:00 AM

DNA
Posts: 130

I have made my site with 2 languages with this tutorial:
http://modxcms.com/forums/index.php/topic,29597.0.html

But the problem is now, that i can't get the &hereclass correctly.

The ACTIVE class is in the language selector. And i can't figure out why:
Code:
<ul  id="sprachwahl">
<li class="active"><a href="http://127.0.0.1/wnh/nl/aanbiedingen.html"><img src="/wnh/assets/templates/wnh/images/nl.gif" alt="nl" /></a></li>
<li class="last"><a href="http://127.0.0.1/wnh/cn/aanbiedingen.html"><img src="/wnh/assets/templates/wnh/images/cn.gif" alt="cn" /></a></li>

</ul>

But it has to be in:
Code:
<ul><li><a href="http://127.0.0.1/wnh/" title="Home" id="nRed">Home</a></li> 
<li><a href="/wnh/nl/aanbiedingen.html" title="Aanbiedingen" id="nPurple">Aanbiedingen</a></li> 
<li><a href="/wnh/nl/recepten.html" title="Recepten" id="nGreen">Recepten</a></li> 
</ul>


#54: 10-Jul-2009, 11:29 AM


elz64
Posts: 427

WWW
Hi,

I don't know if some of you have the same question I have :

We re trying to improve some lacks in this multilang system.
Most of all the main lack is the (not)  nlogin management.

We are trying some handmade solution to deal with the routing to the correct LOGIN page (wich is unique by definition in MODx) and that must be, now, in the correct language too.

So we created in the folder that contains 'errorpage' and some other stuff a 'go-login' page wich is referenced into the MODx configuration as the "goto for login".

However we are now paining to recreate the natural routing process of MODx:
  • url requested (protected) -> redirection by MODx to the referenced page 'go-login' ->back to requested page once loged
  • Now we have introduced a supplementary level of redirection with a 'redirect' snippet that goes to the current language login page. (checks language cookie...)
  • At this point MODx will lost the original route process and won't be able anymore to go back to the first requested page then,
  • once the user has loged in, we should invent a process to recreate the  re routing to the first requested url.
Well this is not done yet.

Any suggestion will be appreciated.

Thank you
Schtroumpf Grognon - Grouchy Smurf
---------------------------------
Faites pas attention.. - Don't pay attention

#55: 20-Jul-2009, 04:32 AM

bvandorp
Posts: 10

I have a question which i cant quite answer myself after reading this topic.

Is it necessary to keep the different languages identical to each other? So if you create an extra page on the english part should it be created on the other languages as well?

thanks in advance.

#56: 20-Jul-2009, 04:41 AM

x0149128
Posts: 411

I have a question which i cant quite answer myself after reading this topic.

Is it necessary to keep the different languages identical to each other? So if you create an extra page on the english part should it be created on the other languages as well?

thanks in advance.

Only if you want that page translated into the different language. E.G say you have a page called "products" for each language. When you click on the country icon you are taken to the product page of that country.  If you don't have the same content in each language you are best to only use the flags, language selector on the home page of each countries site, see link removed
« Last Edit: 1-Dec-2009, 09:41 AM by x0149128 »

#57: 22-Jul-2009, 11:19 AM

aceman3000
Posts: 26

Hi sorry to bother you. But I was wondering how your website redirects to different TLDs as I need to do this for a site at www.naturediet.co.uk
So you want different TLDs, huh? There you go Smiley

Make a new Plugin "redirectDomain" (or name it whatever you like)
and check "OnWebPageInit" under Events.
Insert following Code:
Code:
$e = &$modx->event;
$domains[] = array('url'=>'www.mydomain.de','id'=>72);
$domains[] = array('url'=>'www.mydomain.ch','id'=>920);
$domains[] = array('url'=>'www.mydomain.fr','id'=>242);
$domains[] = array('url'=>'www.mydomain.nl','id'=>494);
$umleitung = false;
$host = $_SERVER['HTTP_HOST'];

if($e->name=='OnWebPageInit') {
foreach ($domains as $domain){
// Wenn beim ersten Aufruf der Seite (site_start) der host == URL ist
if($host == $domain['url'] && $modx->documentIdentifier == $modx->config['site_start']){
$modx->sendRedirect($modx->makeUrl($domain['id'], '', '', 'full'));
exit;
}
}
}

In the array $domains enter your domainnames and the id of the corresponding parent folder and you have it.

Hope i could help. Let me know if something doesn´t function as expected.

Carl: Please don´t send your messages as private because other people could answer as well, or maybe someone is interested in your question and or the solution.

Greetings
aceman

#58: 23-Jul-2009, 09:08 PM

biggerbrother
Posts: 21

Hey,

Is the only way to see what language you're in (whe you have language specific images or text) when you are in PHP code this variable: $_COOKIE['LanguageID']Huh

Thanks!

#59: 8-Sep-2009, 05:21 AM

octoris
Posts: 3

Question.... is there a need or good reason to use the iso country codes? It's a language option so wouldn't it be logical to go for iso language codes like en for english and sv for swedish

#60: 21-Sep-2009, 01:52 AM

grunberg
Posts: 2

Hi,

Can anybody update the tutorial here as well as the wikis one (http://wiki.modxcms.com/index.php/Make_Multi_Lingual_Site) with proper (step by step) way to build multilingual website in Revolution?!?  As newby I have no idea how to use context mentioned somewhere before and I'm not sure if it's worth to learn the older versions of MODx to find out that there is no point to use those methods on Revolution...

Thanks in advance Smiley
Pages: 1 2 [3] 4   Go Up
0 Members and 1 Guest are viewing this topic.