Categories sidebar - wrong language for title

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
scratch
Regular
Posts: 8
Joined: Sun Aug 10, 2008 7:04 pm

Categories sidebar - wrong language for title

Post by scratch »

I'm having a small problem with the language the title of the "category" plugin uses in the sidebar. I've set serendipity to use the language of the users browsers, and while that works flawlessly with everything else, the category box only uses the title that has been entered in the admin panel. Oddly enough, the title is being displayed in the correct language in the admin panel (plugins page, where all the active / inactive plugins are being shown).

Ideas?
scratch
Regular
Posts: 8
Joined: Sun Aug 10, 2008 7:04 pm

Post by scratch »

Ok, could anybody help me fix this? I do have some knowledge in PHP, HTML and so on, but i'm rather new to the s9y cms.

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

Post by garvinhicking »

Hi!

Sadly, this is a small shortcoming, because s9y does only replace generic titles for plugins, and as soon as you enter a custom name, it sticks for all languages.

So in your case I believe it would only work if you "reset" the stored category title. Does entering a "0" or " " (space) in the title of the category properly revert the name? You might want to check the serendipity_config DB table to remove the serendipity_categories_plugin:...../title variable.

On the long-run, this is one of the places where the s9y core would need more multilingual abilities...

HTH,
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/
scratch
Regular
Posts: 8
Joined: Sun Aug 10, 2008 7:04 pm

Post by scratch »

Clearing the title or deleting the DB entry doesn't help. As i said, the title is displayed in the correct language on the plugins page in the admin panel, but not on the frontpage, so my guess is that there is some code missing for the frontend. I just don't know where to look for that.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

No, it's simply because in the admin backend, the static plugin title is evalutated, but for the frontend only the configured title will be pulled.

When the 'title' is not existing in the serendipity_config DB table, it cannot use the name you entered, because this is the only place where it got stored -- only the constant name should be available then. Maybe you did not delete the proper row?

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/
scratch
Regular
Posts: 8
Joined: Sun Aug 10, 2008 7:04 pm

Post by scratch »

Oh well, still doesn't work. When i delete the db entry s9y will immediately create a new one with the title of the category box in the current language. Then of course it doesn't change when i switch languages, since, as you say, the title is being pulled from the db.

Seems i can't get this to work.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Yeah, once you deleted the row, this workaround will only work as long as you do not re-configure the plugin and save the string again! You must delete this after every save, until the s9y can find a proper solution for multilingual plugin titles.

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/
scratch
Regular
Posts: 8
Joined: Sun Aug 10, 2008 7:04 pm

Post by scratch »

No, the plugin creates the entry in the config table automatically, i didn't reconfigure it. I just tried it again: Deleted the db entry, refreshed the blog page, db entry is there again. I guess I'd have to disable the creation of that entry, but how? The plugin doesn't appear to be located in the plugins folder.

Strange though, the "Recent entries" plugin works as intended, it switches the language of the box title as soon as the browser language changes, and so does the archives plugin.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hhm. This might have been an optimization that I missed then, I'm sorry.
Strange though, the "Recent entries" plugin works as intended, it switches the language of the box title as soon as the browser language changes, and so does the archives plugin.
Yes, but those plugins do not allow you to configure your own sidebar title.

I believe the only way to get this done then currently is this one:

1. You enter a constant name for the title by configuring the plugin. Insert the string "CATEGORIES" (this is the actual s9y name for it)

2. Now edit your sidebar.tpl template file of the template you're using. Copy it over from templates/default/ if your template does not yet have it. For bulletproof templates, this code looks like this:

Code: Select all

<h3 class="serendipitySideBarTitle {$item.class}">{$item.title}</h3>
By default this uses the string saved in the DB for the output, but we now want to use the CONSTANT name you entered. Thus we now use this code:

Code: Select all

<h3 class="serendipitySideBarTitle {$item.class}">{$item.title|serendipity_constant}</h3>
3. This now requires a smarty function "serendipity_constant" that you need to declare in your config.inc.php file of your template (Create an empty php file if your template does not have it yet) with this code:

Code: Select all

function serendipity_constant($zeichenkette) {
  if (defined($zeichenkette)) {
    return constant($zeichenkette);
  } else {
    return $zeichenkette;
  }
}
$serendipity['smarty']->register_modifier('serendipity_constant', 'serendipity_constant');
Now you should get the proper constant name instead of a hard-coded string. You could also use your own constant names defined in lang_*.inc.php files of your template directory, instead of the internal s9y ones...

HTH,
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/
scratch
Regular
Posts: 8
Joined: Sun Aug 10, 2008 7:04 pm

Post by scratch »

Ah, i see. It works now, and this hack will probably prove useful in the future. Thanks!
Post Reply