Multi-'language'

Multi-'language', a forum discussion on Jojo CMS. Join us for more discussions on Multi-'language' on our Plugin Announcements forum.

Back to Forum Index : Back to Plugin Announcements   RSS
tom

Developer

tom

27 Aug 2010
Posts: 379

OK, I'm about ready to commit an experiment in altering the way this system works.

It shouldn't affect anything other than the articles plugin which I've adjusted to use the new approach, as I've left the existing system in place. But it does screw around with core a good deal, so approach with caution. Basically I just want y'all to have a look at it and see what you think. It can be reverted if it seems too wacky.

Why? Same reason as forcing categories really - at the moment it's too easy for clients to screw up their sites and then grumble about it. They should be able to add a new blog / gallery / whatever page and it should just work: hence the category changes.

Same with multi-language sites - they should be able to add a new page to a sub-site and not have to think about setting the Language/Country field correctly for it to work. If they put it in that tree it should belong to that tree with no questions asked. They shouldn't have to think about assigning an HTML language for the page either if it's already been set as the default in lang_country.

Also 'Language/Country' is a misnomer - it can be either of those two or neither, it's just the sub-site section that page belongs to. And it's further confused by the Language field (which for multi-language sites ie: sites that are sectioned by language) seems redundant, but actually isn't.

So, what I've done, just for the articles plugin, is remove all reference to the 'pg_language' field (which doesn't actually set the 'language' necessarily - it sets the lang/country). The ar_language field was confusingly being used get the pageurl prefix which didn't make much sense when categories take care of that everywhere else, so I've replaced it with the pageid in getArticleUrl (I haven't actually removed the field, it just doesn't do anything anymore).

Instead, using the pageid (either from the page itself for articles pages or from the article array which gets it from the category), it checks the top of the selectedPages tree to find the root page, checks the mldata for a matching root page in the lang_country table and uses that to work out what section it's in.

I've left the getMultiLangString function in there for legacy use, but articles now uses the new (and hopefully less confusingly named) getPageUrlPrefix function instead to do the same job.

It does mean a lot of calls to selectedPages and mldata, but as far as I can see both of these are cached (or could be) so it shouldn't actually add much in the way of overhead.

Eventually, it will mean that the Lang/Country field can be hidden (and set by an after_save event), and once all plugins have been updated to not use it, it can be removed altogether. That way all sub-section info can be handled in one place - the lang_country table - and all plugins can use one central function (taking a pageid) to find out what the url prefix is, default html language settings etc.

I haven't made it as all-pervasive as it could be - many parts of core still use the pg_language system - but I thought I'd commit it first and see what you think before taking it further.

I'm not getting any errors on it here and I've tested it against multi and single sites, sitemap, search, rss, and other (untouched) plugins etc, so as far as I can tell it's safe, but given the level of re-arrangement there are bound to be cases where it does something not quite right. It's an experiment.

tom

Developer

tom

6 Sep 2010
Posts: 379

Have pushed this a bit further and it seems pretty robust. In all cases I've come across so far, reference to multilanguage or pg_language can be dropped altogether and everything worked out from the section root (even for non-multi-language sites - the section root in lang_country for single section sites is set as 0 as a default).
Back to Forum Index : Back to Plugin Announcements   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.