Welcome to Geeklog, Anonymous Tuesday, November 26 2024 @ 03:20 pm EST
Geeklog Forums
Problem with multilingual support
Status: offline
mystral-kk
Site Admin
Admin
Registered: 03/19/06
Posts: 100
Location:Japan
Hi all, I think I've found a bug with GL's multilingual support. Let me explain.
At a multilingual-aware site, objects have ids with '_' (underscore) and lnaguage shortcuts at their tail, for example, 'Introduction_en', 'Introduction_de'.
In displaying contents, Geeklog uses COM_getLangSQL() and identifies the current langugae a user prefers.
This is implemented in COM_getLangSQL() at line 5940,
$sql = ' ' . $type . " ({$table}$field LIKE '%_$lang_id')";
'%' is a wildcard character in SQL, equivalent to '*' in regular expressions. So this code intends "Select ids which ends "_$lang_id".
Unfortunately, '_' is a wildcard character in SQL, equivalent to '.' in regular expressions.
http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html
Thus, line 5940 picks up any ids which end with any given language shortcuts **WITHOUT** a preceding '_'.
This is a bit inconvenient and inconsistent.
-- mystral-kk, "Every cloud has a silver lining."
Text Formatted Code
$sql = ' ' . $type . " ({$table}$field LIKE '%_$lang_id')";
-- mystral-kk, "Every cloud has a silver lining."
12
9
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
This is a better mysql referrence for LIKE: http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
16
12
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Nice find, thanks.
It shouldn't be a problem in practice, though. When you're using the multi-language setup, all items with IDs not following the "_lng" pattern wouldn't normally be displayed, so it's unlikely that you will have any items that accidentally match anyway.
Still should be fixed, of course.
bye, Dirk
It shouldn't be a problem in practice, though. When you're using the multi-language setup, all items with IDs not following the "_lng" pattern wouldn't normally be displayed, so it's unlikely that you will have any items that accidentally match anyway.
Still should be fixed, of course.
bye, Dirk
16
15
Quote
Status: offline
mystral-kk
Site Admin
Admin
Registered: 03/19/06
Posts: 100
Location:Japan
Thanks for good info, jmucchiello. so all we have to do is change line 5940 from
$sql = ' ' . $type . " ({$table}$field LIKE '%_$lang_id')";
to
$sql = ' ' . $type . " ({$table}$field LIKE '%\_$lang_id')";
Dirk, I'm afraid you have some misunderstanding about '_' character. '_' in SQL matces any one character including '_' itself. Suppose you are going to setup a mutilingual-aware site where visitors can choose between English (shotcut 'en') and German ('de') and you have an article whose id is 'Freunde'.
The moment you enable $_CONF['languages'] and $_CONF['language_files'] arrays, all artciles will 'disappear' to all the visitors, but the 'Freunde' artcile will still be displayed to German-speaking people.
-- mystral-kk, "Every cloud has a silver lining."
Text Formatted Code
$sql = ' ' . $type . " ({$table}$field LIKE '%_$lang_id')";
Text Formatted Code
$sql = ' ' . $type . " ({$table}$field LIKE '%\_$lang_id')";
-- mystral-kk, "Every cloud has a silver lining."
20
18
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
No, I understand the problem perfectly (and I tested it with another German word ending in ...de).
What I'm saying is that if you're running a site with multi-language support enabled, you will usually not have any stories (or other items) whose IDs end in anything other then _en, _de, etc. anyway.
bye, Dirk
What I'm saying is that if you're running a site with multi-language support enabled, you will usually not have any stories (or other items) whose IDs end in anything other then _en, _de, etc. anyway.
bye, Dirk
17
17
Quote
Status: offline
mystral-kk
Site Admin
Admin
Registered: 03/19/06
Posts: 100
Location:Japan
Ah, I got it. Thanks for the reply, Dirk.
BTW, when I enabled multilingual support on my site, stories without language IDs were displayed in the 'Older Stories' block. When I hit the links, the articles were displayed. I wonder if there is a quick and easy way to fix this.
-- mystral-kk, "Every cloud has a silver lining."
BTW, when I enabled multilingual support on my site, stories without language IDs were displayed in the 'Older Stories' block. When I hit the links, the articles were displayed. I wonder if there is a quick and easy way to fix this.
-- mystral-kk, "Every cloud has a silver lining."
17
16
Quote
Status: offline
mystral-kk
Site Admin
Admin
Registered: 03/19/06
Posts: 100
Location:Japan
I updated some stories in the 'Older Stories' block and added a new one on my multilingual site. Surely the contents of the 'Older Stories' block were updated, but stories **without** languages IDs are still displayed in the block. I wonder if this is what's supposed to happen.
-- mystral-kk, "Every cloud has a silver lining."
-- mystral-kk, "Every cloud has a silver lining."
15
15
Quote
All times are EST. The time is now 03:20 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content