Forums / Cotonti / Extensions / Multilanguage and news plugin

howto

ez
#1 2010-09-09 05:11
Hi,

I have a question...What if I want to use multilanguage news items.

The news plugin lets you use {INDEX_NEWS}, but i really want something like
{INDEX_{PHP.usr.lang}-news} (if you get my drift.. :) )


Where I have the following categories:

nl-news
en-news

What is/are the best way(s) to solve this...

tnx
==- I say: Keep it EZ -==
GHengeveld
#2 2010-09-09 16:09
Rewrite the news plugin I guess (and release it here). I think you should keep the news category as a fallback (the default language) and use 'en-news' if the user has english configured (dutch being the default) and just 'news' for dutch users.

if (usr.lang != cfg.defaultlang) ...
ez
#3 2010-09-09 17:35
Hi Gert,

Tnx..I am already rewriting the news plugin for language support... ;)
And got it to work!!

Index Template (TPL):
<div class="block">
 {INDEX_NEWS_NL_NL_NEWS}
 {INDEX_NEWS_EN_EN_NEWS}
</div>

In the news.php i do:
  $ttmp=sed_get_news($v[0], "news.".$v[0], $v[1], $dadd, $v[2]);
  $t->assign("INDEX_NEWS_".strtoupper($v[0]), $ttmp);
  //sed_watch("INDEX_NEWS_".strtoupper($usr['lang'])."_".strtoupper($v[0]), $ttmp);
  $t->assign("INDEX_NEWS_".strtoupper($usr['lang'])."_".strtoupper($v[0]), $ttmp);

My pagecategories are named:
en_homepage
en_news
nl_homepage
nl_news

Notice the use of '_' instead of '-'
It turned out that Xtemplate cannot use '-' in the assign ?????


And I got separate tpl files for all separate news cats..
You cannot use the rewrite rules from the i18n example.. it needs '_'.

------------------------------------------------------------------------
Good idea about the original news cat as a fallback, I will use that!

Releasing it will be difficult, because i have a custom news plugin..
I use a half baked 0.9 news plugin with additional hooks and other stuff I changed.
==- I say: Keep it EZ -==
Kingsley
#4 2010-09-09 21:29
Sick, this is nice.. will follow this closely :D
ez
#5 2010-09-14 04:16
I keep on busy with this multilanguage site... :)

I am now adding very nice stuff to the recentitems plugin.
So this will become language aware (as I call it).. (optinal off course)

But I am still wondering.... Why must I make these things..
Shouldn't this be in the standard cotonti package ?? (I mean this is NO rocket science I am making)

What do others think off multilanguage in the default Cot ??


I am asking this because I am making to much 'corehacks', so upgrading will be more difficult for me, and that is something I would like to avoid...

Added 56 days later:

@Trustmaster:

I see in the project tracker that you are starting Internationalization... :D

I have some things already made and some 'good' ideas.
Maybe I can help ?
==- I say: Keep it EZ -==
This post was edited by ez (2010-11-10 04:13, 13 years ago)
Trustmaster
#6 2010-11-10 05:47
Sorry, I'm not posting any technical details on its implementation until the work is actually finished. It works on top of structure and pages without affecting them, as a plugin that stores i18n data in separate tables and provides interface for translation editing.
May the Source be with you!
ez
#7 2010-11-10 06:07
no prob..
==- I say: Keep it EZ -==