multilingual static page feature request

Creating and modifying plugins.
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

multilingual static page feature request

Post by carl_galloway »

Hi guys, the static pages plugin with multilingual support is something that seems to have been asked about for a long time, and I know very significant progress has been made, but can I request the following changes which I think most users of these two plugins would really appreciate.

1. Can the startpage in the static pages plugin be set by language. So a German site visitor would see the german startpage, and an english visitor would see the english startpage. At present only one startpage can be set. I'm thinking a simple language check could be added which then identifies all pages with the startpage setting and simply displays the first page that satisfies both language and startpage set. I hope this isn't too much effort.

2. Could the static pages sidebar plugin be configured to show only pages from the specific language of the user, or if there aren't any pages then default to the serendipity default language (the one set in the configuration screen of admin). I know this isn't easy, and I also know that many users have been recommended to use the multilingual html nugget, but frankly this is a double effort, and requires some knowledge of html, whereas the excellent static pages sidebar plugin already does what users need it to do, just not multi-lingually.

Thanks guys, Carl
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

bump - sorry :D
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Sadly this is not very trivial to achieve. I just have prepared this patch for your first wish:

Code: Select all

Index: serendipity_event_staticpage.php
===================================================================
RCS file: /cvsroot/php-blog/additional_plugins/serendipity_event_staticpage/serendipity_event_staticpage.php,v
retrieving revision 1.89
diff -u -r1.89 serendipity_event_staticpage.php
--- serendipity_event_staticpage.php    1 Oct 2006 15:35:41 -0000       1.89
+++ serendipity_event_staticpage.php    10 Oct 2006 07:34:38 -0000
@@ -67,7 +67,7 @@
         $propbag->add('page_configuration', $this->config);
         $propbag->add('type_configuration', $this->config_types);
         $propbag->add('author', 'Marco Rinck, Garvin Hicking, David Rolston, Falk Doering');
-        $propbag->add('version', '3.36');
+        $propbag->add('version', '3.37');
         $propbag->add('requirements',  array(
             'serendipity' => '0.8',
             'smarty'      => '2.6.7',
@@ -1239,6 +1239,9 @@
         $q = 'SELECT pagetitle
                 FROM '.$serendipity['dbPrefix'].'staticpages
                WHERE is_startpage = 1
+                 AND (language = \'' . $serendipity['lang'] . '\'
+                  OR  language = \'all\'
+                  OR  language = \'\')
             ORDER BY id DESC
                LIMIT 1';
         $page = serendipity_db_query($q, true, 'assoc');
Can you tell me if that works out for you?

About your second wish, as I read the code of the current staticpage plugin list:

Code: Select all

    $q = 'SELECT id, headline, parent_id, permalink, pagetitle
                FROM '.$serendipity['dbPrefix'].'staticpages
               WHERE showonnavi = 1
                 AND publishstatus = 1
                 AND (language = \''.$serendipity['lang'].'\'
                  OR  language = \'\'
                  OR  language = \'all\')';
This already fetches a list of the current language to the user?! In which regard does that not work?

I'm not working often with the static pages, and Falk is loaded with work, so please excuse me if I get fundamental parts wrong. :-/

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Thanks Garvin, now for the embarassing part. I resorted all my bookmarks a while ago, and I seem to have lost the bookmark for the repository. I need the http address of the patched file to download it.

Thanks, Carl
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Uhm, I did not yet submit the patch because I wanted you to try it out. :)
I've uploaded the pasted code here:

http://rafb.net/paste/results/8mqD6G51.html

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Thanks Garvin, unfortunately it doesn't seem to work, its still only producing the english version as the startpage, and when I use the multilingual sidebar to select german the default overview pages are appearing instead of the german language static page which has been configured as startpage. I also changed the order of the static pages so that the german page was in front of hte english page and it still didn't work.

You're right about the static pages sidebar plugin, and I need to really study this more because it doesn't seem to be reliable.
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Ok, its taken me a while to retest Garvin's patch, and I can now confirm that in fact it does work as requested.

Its not perfect, let me tell you how it does work. If the browser /computer language is set to German then the patch works flawlessly.

However if the language is set to any other language and the user tries to see the german pages using the multilingual sidebar selector (drop down to choose language) then it doesn't work, and reason for this is that the dropdown selector automatically refers the user to 'index.php?user_language=en (or whichever language has been selected), and for some reason index.php simply brings up the default blog entries forht elanguage chosen, but what it should be doing is checking to see if a static page has been selected as the startpage for the language. I guess this is not trivial, so is it possible to place a static link into the template that changes the language and links to a static page?

Thanks, BTW Garvin, I think it might be safe to commit your patch for the static page startpage in different languages, we just need to figure out why the multilingual plugin isn't doing what is requested.

Carl
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I'd be surprised if you couldn't just add the user_language variable to the link to the static page. That should send you to the appropriate page in the appropriate language.

I hope.
Judebert
---
Website | Wishlist | PayPal
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Hi jude, I tried that, and it doesn't seem to work.

What I found is that if I use index.php?user_language=de/pages/staticpage.html - I get redirected to the blog overview page with no language selected

index.php?user_language=de?/pages/staticpage.html - same as above

index.php/pages/staticpage.html?user_language=de - I get the blog overview page again, but the language has changed to german.

You are probably right, but what am I missing, why can;t I have the static poage load, and also change the language to german?

Carl
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I think what you need is: index.php?user_language=de&serendipity[subpage]=/pages/staticpage.html
Judebert
---
Website | Wishlist | PayPal
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

No that didn't work either, the problem seems to be that if the browser/os language is set differently, then you can either have the language and the blog entries, or the static page in the default language but not both. Seems to be a fundamental flaw in the way the language settings are defined. I know I'm probably the only person making the request, but multilingual s9y installs are popping up all ove rhte place and I think this is one of those features that probaly needs to be thought about. So many of us use static pages now.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

And unfortunately, I'm not a multilingual sort of person, so I'm going to have to pass it off to someone else.

Rats. I really thought the plugin would trigger on the user_language variable. It's probably just that another variable needs to be set, too.
Judebert
---
Website | Wishlist | PayPal
ormus7577
Regular
Posts: 122
Joined: Sat Nov 04, 2006 12:11 pm
Location: Ulm, Germany

Post by ormus7577 »

Don't you just love 'ancient' threads being dragged into daylight again? :D

Fear not, I'm on this topic. The flaw is very minor, as a matter of fact the static page plugin is perfectly able to handle multiple start pages for different languages. It just has an error in the way the start page is checked for...

Now that I've found it, I'll try to fix it tonight...
my installations:
family blog: http://familie.lobenstein.info/
personal blog: http://www.ormus.info/
OrmusTool Homepage: http://tool.ormus.info/
Online Adventskalender: http://www.ormus.info/pages/advent.html
ormus7577
Regular
Posts: 122
Joined: Sat Nov 04, 2006 12:11 pm
Location: Ulm, Germany

Post by ormus7577 »

Ok, I'm a liar ;) The mistake is somewhere else and I couldn't wait until tonight...

The mistake is actually in functions_permalinks.inc.php, in function serendipity_currentURL.

There's a line:

Code: Select all

$url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?' . $uri['path'] . $qst;
Now if there is no query string (read $qst is empty), there should be no '?' in the url, right?

So it should be something like this one:

Code: Select all

    if (!empty($qst)) {
        $url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?' . $uri['path'] . $qst;
        } else {
        $url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'];
        }
The above mentioned error with the static start pages for different languages is fixed with that, can't rule out possible side effects though...

Garvin, your opinion on that?
my installations:
family blog: http://familie.lobenstein.info/
personal blog: http://www.ormus.info/
OrmusTool Homepage: http://tool.ormus.info/
Online Adventskalender: http://www.ormus.info/pages/advent.html
ormus7577
Regular
Posts: 122
Joined: Sat Nov 04, 2006 12:11 pm
Location: Ulm, Germany

Post by ormus7577 »

Now that I read my own code, it should probably check both $uri['path'] and $qst for being empty...
my installations:
family blog: http://familie.lobenstein.info/
personal blog: http://www.ormus.info/
OrmusTool Homepage: http://tool.ormus.info/
Online Adventskalender: http://www.ormus.info/pages/advent.html
Post Reply