Recently, I started using a theme that uses global navigation on my multilingual blog. One thing I would have liked to see was having an option to show different navbar items depending on the language selected. Basically, providing navbar items in appropriate languages.
Would it be possible to tack on a language selection box on the existing framework, or should I just do away with the global navigation and have a custom array just for the theme?
Possibility of adding multilingual navbar support?
Possibility of adding multilingual navbar support?
I make s9y plugins, too.
My s9y blog depends on them.
My s9y blog depends on them.
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Possibility of adding multilingual navbar support?
I believe adding a language selection checkbox that toggles additional input fields there would be quite complicated.
I'd rather suggest you create one additional menu item in the configuration for each language, and then depending on the language you later pass the corresponding menu item to the output.
HTh,
Garvin
I'd rather suggest you create one additional menu item in the configuration for each language, and then depending on the language you later pass the corresponding menu item to the output.
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/
# 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/
Re: Possibility of adding multilingual navbar support?
That sounds sensible. I'll give it a try. Thanks.
I make s9y plugins, too.
My s9y blog depends on them.
My s9y blog depends on them.
Re: Possibility of adding multilingual navbar support?
Alright, I got it working! I made it so that you get a dropdown box for each navigation item's language. You can pick "All" or a specific language, like the current multilingual HTML nugget plugin.
My website http://tool-box.info/blog/ has five menu items assigned to each of the two languages it's in (English and Korean) for a total of ten. Switching the language will show the appropriate five.
My website http://tool-box.info/blog/ has five menu items assigned to each of the two languages it's in (English and Korean) for a total of ten. Switching the language will show the appropriate five.
I make s9y plugins, too.
My s9y blog depends on them.
My s9y blog depends on them.
Re: Possibility of adding multilingual navbar support?
I wish your dancing panda could stand still. Its hard to concentrate with this up and down...
Maybe you can give a working code example for others to build this into their theme too?
Maybe you can give a working code example for others to build this into their theme too?
Regards,
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Re: Possibility of adding multilingual navbar support?
It was a quick-and-dirty implementation involving adding of a variable into the existing array.
In the config.inc.php file, instead of calling out this function:
I added a block of code that does the same thing, plus accepting a language variable:
At first, I added the code for the language variable after calling out serendipity_loadGlobalThemeOptions, but then the dropdown box for the language appeared together at the bottom of the page, so I went with this way.
Then in the index.tpl of the theme, the navbar rendering implements "navlink.language" like so:The initial {if}{elseif} should filter out a menu item if it's not assigned to the correct language.
P.S. The avatar is the dancing badger from the 2003 fiash animation that was quite famous back then.
In the config.inc.php file, instead of calling out this function:
Code: Select all
serendipity_loadGlobalThemeOptions($template_config, $template_loaded_config, $template_global_config);
Code: Select all
$navlinks = array();
$conf_amount = array(
'var' => 'amount',
'name' => NAVLINK_AMOUNT,
'type' => 'string',
'default' => '5',
'scope' => 'global'
);
$template_config[] = $conf_amount;
if (!isset($template_loaded_config['amount']) || empty($template_loaded_config['amount'])) {
$template_loaded_config['amount'] = $conf_amount['default'];
}
for ($i = 0; $i < $template_loaded_config['amount']; $i++) {
$navlinks[] = array(
'title' => $template_loaded_config['navlink' . $i . 'text'],
'href' => $template_loaded_config['navlink' . $i . 'url'],
'language' => $template_loaded_config['navlink' . $i . 'lang']
);
$template_config[] = array(
'var' => 'navlink' . $i . 'text',
'name' => NAV_LINK_TEXT . ' #' . ($i+1),
'type' => 'string',
'default' => 'Link #' . ($i+1),
'scope' => 'global'
);
$template_config[] = array(
'var' => 'navlink' . $i . 'url',
'name' => NAV_LINK_URL . ' #' . ($i+1),
'type' => 'string',
'default' => '#',
'scope' => 'global'
);
$template_config[] = array(
'var' => 'navlink' . $i . 'lang',
'name' => INSTALL_LANG . ' #' . ($i+1),
'type' => 'select',
'default' => 'all',
'select_values' => array('all' => COMMENTS_FILTER_ALL,
'en' => 'English',
'de' => 'German',
'da' => 'Danish',
'es' => 'Spanish',
'fr' => 'French',
'fi' => 'Finnish',
'cs' => 'Czech (Win-1250)',
'cz' => 'Czech (ISO-8859-2)',
'nl' => 'Dutch',
'is' => 'Icelandic',
'se' => 'Swedish',
'pt' => 'Portuguese Brazilian',
'pt_PT' => 'Portuguese European',
'bg' => 'Bulgarian',
'hu' => 'Hungarian',
'no' => 'Norwegian',
'ro' => 'Romanian',
'it' => 'Italian',
'ru' => 'Russian',
'fa' => 'Persian',
'tw' => 'Traditional Chinese (Big5)',
'tn' => 'Traditional Chinese (UTF-8)',
'zh' => 'Simplified Chinese (GB2312)',
'cn' => 'Simplified Chinese (UTF-8)',
'ja' => 'Japanese',
'ko' => 'Korean'),
'scope' => 'global'
);
}
$serendipity['smarty']->assignByRef('navlinks', $navlinks);
Then in the index.tpl of the theme, the navbar rendering implements "navlink.language" like so:
Code: Select all
<ul>
{foreach from=$navlinks item="navlink"}
{if $navlink.language!='all'&&$navlink.language!=$lang}
{elseif $navlink.title!=""&&$navlink.href!=""}
<li>
{if $currpage==$navlink.href or $currpage2==$navlink.href}
<span>
{else}
<a href="{$navlink.href}">
{/if}
{$navlink.title}
{if $currpage==$navlink.href or $currpage2==$navlink.href}
</span>
{else}
</a>
{/if}
</li>
{/if}
{/foreach}
</ul>
P.S. The avatar is the dancing badger from the 2003 fiash animation that was quite famous back then.
I make s9y plugins, too.
My s9y blog depends on them.
My s9y blog depends on them.
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Possibility of adding multilingual navbar support?
Nice! Thanks for sharing the code. Even though it's not the most elegant solution due to s9y's restriction, I think it is cool to be able to workaround that
# 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/
# 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/