2012-03-06, 09:25:56 (This post was last modified: 2012-03-06, 09:26:22 by wad.)
This plugin automatically generates language menu with links to change language and stay on same page.
Requirements: mvlcek's i18n plugin.
Instuctions: set caption for each language, name class for current language <li> (in navigation menu it is 'current') and it is ready to be used in your theme template!
Don't forget to provide <ul> tags (you may add your own attributes to them), because this plugin generates only <li> elements.
Example of usage in theme template:
add image support (icons or png's instead of/in addition to text caption)
add drag'n'drop support to settings menu for customizable language order
@mvlcek I don't mind if you use part of souce code of this plugin or whole plugin itself in your next i18n plugin release (i.e. make it core functionality of your plugin)
Zorato Wrote:This plugin automatically generates language menu with links to change language and stay on same page.
To-Do list:
add image support (icons or png's instead of/in addition to text caption)
add drag'n'drop support to settings menu for customizable language order
Thanks for extending the I18N plugin.
The language switching was never a priority for me because it's a one-time setup in the template and - as your To-Do list shows - not that easy to implement, if it should fit for everybody.
But it definitely will simplify the setup for the language links.
Regarding your plugin: you must not save data in the plugins folder, you should use /data/other instead.
Suggestion: you can include the language/country combinations from e.g. here in your plugin and show the user a list with the flags corresponding to the language from here. When the user selects a flag, you can automatically download it to e.g. the data/downloads/flags folder and use it in your link.
(2013-07-05, 00:24:31)phpman Wrote: sorry that i reactivate this old post but i don´t understand what i must do to display "flags" insead of letters for the languages.
Can somebody help in this case ?
Thanks in advance.
I used to insert whole <img /> tag with src="" and alt="" attributes. It wasn't very easy, but worked for me.
In the file page, create a folder called "flag" and copy images of flags you need. Files must be named as code country et png format.
For instance : en.pgn ; fr.png and so on.
edit file : i18n_lang_menu.php
Into the function get_i18n_lang_menu comment original line and add this :
PHP Code:
function get_i18n_lang_menu(){ //load config $config=get_config(); //hook for <li> class $langs_arr=return_i18n_languages(); $current_language=$langs_arr[0]; foreach($config->languages->children() as $lang){ #echo '<li '.($lang->code==$current_language?'class="'.$config->class.'"':'').' ><a href="'.htmlspecialchars(return_i18n_setlang_url($lang->code)).'">'.$lang->text.'</a></li>'; echo '<li style="list-style-type: none;" '.($lang->code==$current_language?'class="'.$config->class.'"':'').' ><a href="'.htmlspecialchars(return_i18n_setlang_url($lang->code)).'"> <img src="data/uploads/flag/'.$lang->code.'.png" /></a></li>'; } }
I juste add a CSS style to mask li heading and replace $lang->text with image call. As you can see, you can use another folder to store your flag pictures.
2019-03-25, 23:29:39 (This post was last modified: 2019-03-25, 23:45:21 by bokor.pavol.)
Hi Folks,
small issue. I created the site with two languages. CS and PL. CS is default. But, when I opening the site from web browser with different regional settings (e.g. SK), then default language has been changed to regional (SK in this case). I see 3 flags. SK, CS, PL. When I click to CS flag, the SK flag will disappear and everything works fine.
When the pages loads first time, the array ($langs_arr=return_i18n_languages()) print these values "Array ( [0] => sk [1] => cs [2] => en )". When I select CS flag the array print "Array ( [0] => cs [1] => sk [2] => en )".
Weight settings don´t affect. This issue appears when settings "Current menu item display on the dropdown menu bar" is "Hide item" and "Dropdown (Bootstrap)" is on.
(2019-03-25, 23:29:39)bokor.pavol Wrote: Hi Folks,
small issue. I created the site with two languages. CS and PL. CS is default. But, when I opening the site from web browser with different regional settings (e.g. SK), then default language has been changed to regional (SK in this case). I see 3 flags. SK, CS, PL. When I click to CS flag, the SK flag will disappear and everything works fine.
When the pages loads first time, the array ($langs_arr=return_i18n_languages()) print these values "Array ( [0] => sk [1] => cs [2] => en )". When I select CS flag the array print "Array ( [0] => cs [1] => sk [2] => en )".
Weight settings don´t affect. This issue appears when settings "Current menu item display on the dropdown menu bar" is "Hide item" and "Dropdown (Bootstrap)" is on.
Hi i am also having issues with the default language.
I have Swedish for 0
and English for 1
but the site always resorts to English 1 on reset of cookies
(2019-11-22, 00:15:46)Cre8gent Wrote: Hmm i did that but the same happens, plus my shop link now has a /sv/shop instead of /shop so breaks access to the shop.