Jul 05, 2008, 11:10 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Read what MODx Developers say: MODx Dev. Blogs
Pages: [1]   Go Down
  Print  
Author Topic: [Snippet] Multi Lingual - One Stop Solution  (Read 5457 times)
0 Members and 1 Guest are viewing this topic.
Djamoer
Testers
*
Posts: 1,492

No one can limit a man other than the man himself.


WWW
« on: Dec 11, 2005, 10:59 AM »

I created this snippets based on my solution. After looking for some simple solution in integrating Multi Lingual site with MODx, I came up with this solution, so if somebody able to improve it, feel free to modify it and posted it in here.

Special thanks to several people in this forum that helps me a lot in the progress of understandng MODx better and giving me a lot of better idea in bringing this whole Multi Lingual thing.

Thanks to Bravado for pointing me to the right direction.
This solution might lead to modifying several snippet such as NewsListing and etc to support this Multi Lingual site. I'm working on ChildDocumentMapper snippet right now, if somebody willing to do the newslisting snippet, it will be great!

Please read the comment on the code, hope that explains, if not, feel free to figure it out by the code, it's a really simple code, you don't need to be a PHP guru to understand it.

Note: 'domain.com - MultiLingual.snippet.modx.txt' is just the configuration file, you can duplicate this if you have several site running on the same installation.

Sample:
Code:
[!MultiLingual? &ML_action=`Localization` &ML_locale=`2`!]

[!MultiLingual? &ML_action=`LocalizationImage` &ML_locale=`wendy.jpg`!]

[!MultiLingual? &ML_action=`Translation` &ML_varname=`content`!]

[!MultiLingual? &ML_action=`ListLanguage` &ML_listlangchunktpl=`domain.com - MultiLingual ListLang`!]

Have fun!

Best regards,
Wendy Novianto

* MultiLingual.snippet.modx.txt (7.24 KB - downloaded 587 times.)
* domain.com - MultiLingual.snippet.modx.txt (2.18 KB - downloaded 534 times.)
« Last Edit: Dec 11, 2005, 11:03 AM by wendy » Logged

Djamoer
Testers
*
Posts: 1,492

No one can limit a man other than the man himself.


WWW
« Reply #1 on: Dec 11, 2005, 08:39 PM »

Hi guys,

Anybody know how to use mod rewrite?

I'm looking for a way so that the mod rewrite will take 'domain.com/doc/lang_en', 'domain.com/doc/lang_en/', or 'domain.com/index.php?q=1/lang_en' into 'domain.com/doc/?lang=en' or 'domain.com/index.php?q=1&lang=en'.

I really want to eliminate the use of querystring displaying in user browser. If somebofy can helps with it, it will be really great.

Thanks


Regards,
Wendy Novianto
Logged

sottwell
Documentation Team
*
Posts: 7,200



WWW
« Reply #2 on: Dec 12, 2005, 02:23 AM »

I eliminated the query string issue by using a cookie; session can also be used, although that requires some hacking of the login snippet php files, besides timing out.  There are pros and cons to all three methods.
Logged

Live site! sottwell.com - Manager user: guest, password: guestuser
MODx Templates - SkinGraft ready! Loripsum
Djamoer
Testers
*
Posts: 1,492

No one can limit a man other than the man himself.


WWW
« Reply #3 on: Dec 13, 2005, 09:18 AM »

Thanks Susan, but do you have any experience with mod rewrite before? I'm thinking to avoid cookie if possible. I think mod rewrite might be one of the way to do this.

If somebody willing to give it a try, I will be glad to test the regular expression code for the mod rewrite in my site.

Thanks

Sincerelt,
Wendy Novianto
Logged

rthrash
Foundation
*
Posts: 8,910



WWW
« Reply #4 on: Dec 13, 2005, 09:47 AM »

mod_rewrite... what a often tricky beast!

Best resource I've found for it: http://forum.modrewrite.com/

Given a few days, pretty much any challenge you face should be solvable!
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
sottwell
Documentation Team
*
Posts: 7,200



WWW
« Reply #5 on: Dec 13, 2005, 10:01 AM »

Indeed, mod_rewrite is very tricky. It can depend on the server configuration, the server version, and the mod_rewrite module's version as well as how it was compiled. I have hesitated to rely on it for anything much beyond the basics for that reason. And, of course, if you're on a Windows/IIS server, you can pretty much forget it.
Logged

Live site! sottwell.com - Manager user: guest, password: guestuser
MODx Templates - SkinGraft ready! Loripsum
Djamoer
Testers
*
Posts: 1,492

No one can limit a man other than the man himself.


WWW
« Reply #6 on: Dec 13, 2005, 11:53 PM »

Yep,

I have to agree to that. I'm depended heavily on mod rewrite right now, for me to be able to host several sites running on the same MODx installation. Sometimes it does crazy thing, such as when you clear the cache, and you visit the site with other domain, instead of the right domain, then MODx will cache the page with the given base url on the wrong domain, which means that I have to refresh the site, and go through each page one by one using the right domain, so that MODx will cache the right base url. Is there anything better to have mutli site capability in MODx, instead of using mod rewrite and overwrite the other domain to be directed to certain path?

Btw, I found weaknesses in this snippet approach of having Multi Lingual site. When you substitue [*#content*] with [!MultiLingual? &ML_action=`Translation` &ML_varname=`content`!], basically whatever inside the content variable will be written as is, it means that the snippets or other special tag from MODx will not be parsed and displayed correctly by MODx parser, instead it will display them as is.

I guess I still need to use the injection approach using plugin to tap into the default page variables, before they were parsed into the document.
WHat do you guys think about this approach?

Thanks
Logged

dernier_recours
Member
**
Posts: 83



« Reply #7 on: Jan 30, 2006, 10:24 AM »

Hello Wendy,

I'm not used to terms "Localization" and "Internationalization". All I want is to make a website in French and English. I'm not a programmer, but nevertheless I tried to understand this snippet, now for three hours, and still don't understand what it does and how should I begin with my site: make two sets of tree? duplicate each entry in the tree? And what do I do with this snippet?

Thanks a lot!

It would be great to make a tutorial for multilingual sites!  Wink
« Last Edit: Jan 30, 2006, 10:37 AM by dernier_recours » Logged

at the edge of dawn,
you ask yourself if your shadow did follow you down
all night long
Djamoer
Testers
*
Posts: 1,492

No one can limit a man other than the man himself.


WWW
« Reply #8 on: Jan 30, 2006, 10:35 AM »

Hi,

I think this solution is still not done yet. What this thing does is actually use Template Variables as the translation document, intead of duplicating the document tree just for adding another translation. But this approach won't work, if you have a snippet or chunk inside your content.

If you have a simple multi lingual website. You can use the direcotry structure in modx to do the translation, and provide a link to that translated docs. For more advanced use of multi lingual solution, you can try to search this forum. Susan (sottwell) have a good documentation and solution to achieve this.

Let me know what you want to do in detail, and we will help you to choose the best possible solution for you.

Sincerely,
Logged

dernier_recours
Member
**
Posts: 83



« Reply #9 on: Jan 30, 2006, 11:31 AM »

I went through some solutions proposed in the forum. I have to admit that this goes beyond my understanding. What I expect from a multilingual site is more or less what I found with the i18n module of Drupal (http://drupal.org/project/i18n). I read that a solution like Drupal's is under investigation: http://modxcms.com/forums/index.php/topic,6.0.html

For now, my site will not contain lots of files. I will stick on duplicating the directories and use chunks in different languages. As it will become larger, I hope some of the members will know how to find better solution.

I really appreciate your help.
Logged

at the edge of dawn,
you ask yourself if your shadow did follow you down
all night long
Djamoer
Testers
*
Posts: 1,492

No one can limit a man other than the man himself.


WWW
« Reply #10 on: Jan 30, 2006, 11:33 AM »

No Prob.

We'll work on this for sure. By the time we have the solution for this ready, we will put it up on our repository of plugins and snippets for sure.

Thanks for your understanding Wink
Logged

OncleBen31
Sr. Member
****
Posts: 283


I believe in MODx!


WWW
« Reply #11 on: Nov 11, 2006, 02:40 AM »

I'm searching how to add internationalization and localization to MODx. This snippet seems to be very powerfull.
Why this snippet is not in the repository ? Is there an better way to do that ?
Logged
rthrash
Foundation
*
Posts: 8,910



WWW
« Reply #12 on: Nov 11, 2006, 09:45 AM »

The release after 095 will introduce "contexts" into the core of MODx which will make for a huge degree of flexibility. Short response: "yes". Smiley
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!