Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Support for multilanguage sites, Internationalization (I18N)
Please help, what is the easiest way to display the "page title" in menu as subtitle?
get_i18n_navigation(return_page_slug(),0,1,I18N_SHOW_MENU, ???page title???);
Reply
(2015-07-22, 04:34:50)revotron Wrote: Is it necessary to wrap each i18n navigation call inside htmlspecialchars?


Anyone? Big Grin
Reply
(2015-08-07, 04:34:46)revotron Wrote:
(2015-07-22, 04:34:50)revotron Wrote: Is it necessary to wrap each i18n navigation call inside htmlspecialchars?


Anyone? Big Grin

According to the PHP manual, htmlspecialchars encodes HTML characters. In their example, they give:

PHP Code:
$new htmlspecialchars("<a href='test'>Test</a>"ENT_QUOTES);
echo 
$new// &lt;a href='test'&gt;Test&lt;/a&gt; 

If you look at mvlcek's example code, e.g.:

PHP Code:
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url('en')); ?>">english</a

He's using the function so that any valid HTML that incidentally made it into the return_i18n_setlang_url function is encoded, and so the <a></a> HTML tag is not broken by the contents of return_i18n_setlang_url. In short, it's a safety measure in case the language's url contains HTML-breaking characters, and thus should be used.

get/return_i18n_navigation on the other hand is supposed to return valid HTML. So if you want to display return_i18n_navigation properly, don't use htmlspecialchars on it.

(2015-08-05, 18:40:06)xuser Wrote: Please help, what is the easiest way to display the "page title" in menu as subtitle?
get_i18n_navigation(return_page_slug(),0,1,I18N_SHOW_MENU, ???page title???);

I'm guessing that you want to custom render each navigation element? If so, check out the Custom Rendering documentation.
Reply
it also escapes xss injections
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
Thanks for your answer. I know the function of htmlspecialchars. I was just wondering if the plugin functions themselves wouldn't already handle the escaping.
Reply
Hi Guys,

I've upgraded my hosting to something bigger and part of change was also moving data to new location, which has really long path compared to previous. Since that, I have problems saving pages - after clicking Save, I stay on changedata.php so I must refresh and confirm resubmission until it passes OK which is often more than 8 times (and also I get some Unable to read XML! when User Management is enabled).

I get this error:
Code:
[21-Aug-2015 14:54:15 Europe/Belgrade] PHP Fatal error:  Call to a member function addChild() on a non-object in /nfsmnt/hosting2_1/x/7/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxcd70/xxxxxx.xxx/sub/xxx/plugins/i18n_navigation/save.php on line 18

have you seen it before ? can it be caused by long path ? how can I fix it ?
Thank you
Reply
Hi All,

Im using next language switch code as mvlcek wrote in one of his replies from week or a two ago:

<div align="left">
<?php $langs = return_i18n_available_languages(return_page_slug()); ?>
<?php if (in_array('de', $langs)) { ?>
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url('de')); ?>">deutsch</a>
<?php } ?>
<?php if (in_array('de', $langs) && in_array('en', $langs)) { echo '|'; } ?>
<?php if (in_array('de', $langs)) { ?>
 <a href="<?php echo htmlspecialchars(return_i18n_setlang_url('en')); ?>">english</a>
<?php } ?>
</div>

Everything is fine.
Just Im not sure how to set-up the default language?
Using this code my default becomes English and I want DE ..
Also how to setup classes for 'current' language ?

Thanx

Alex
Reply
(2015-08-30, 15:55:55)enri Wrote:
(2015-08-30, 15:46:26)enri Wrote:
(2011-05-18, 23:43:55)mvlcek Wrote:
crusher88 Wrote:First of all, I think there should be a separate forum for the I18N plugin.

A complete support forum? I hope that this topic is enough ;-)

I think this topic is not enough. Your plugin by default simply doesn't work at all and your documents written very weak

It is not obvious even how to make this simple sub menu

<nav id="main-menu" class="level-0">

<ul>
<li><a href="<?php get_site_url(); ?>">Main</a></li>
<li><a href="<?php get_site_url(); ?>services">Services</a></li>
<li class="menu-item-has-children"><a href="about">About Us</a>
<ul class="sub-menu">
<li><a href="<?php get_site_url(); ?>reviews">Reviews</a></li>
</ul>
</li>
<li><a href="<?php get_site_url(); ?>contacts">Contacts</a></li>
</ul>
</nav>

Whoah. Damn, I thought mvlcek's plugins are one of the easiest to use Smile

The menu that you describe is not a challenge at all.

Code:
<nav id="main-menu" class="level-0">
<ul>
<?php get_i18n_navigation(return_page_slug(), 0, 99, I18N_SHOW_NORMAL); ?>
</ul>
</nav>

Note that the li.menu-item-has-children will be li.closed or li.opened. A .currentpath class will be used too. Very handy
Reply
(2015-08-31, 05:56:57)enri Wrote: I tried this before but without playing with li.opened, li.closed and .currentpath because it is not obvious in docs

Just place the php code as shown in the docs and inspect the resulting code - everything will be obvious, I assure you Smile
Reply
(2015-08-24, 23:51:19)alex_d Wrote: Hi All,

Im using next language switch code as mvlcek wrote in one of his replies from week or a two ago:

<div align="left">
<?php $langs = return_i18n_available_languages(return_page_slug()); ?>
<?php if (in_array('de', $langs)) { ?>
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url('de')); ?>">deutsch</a>
<?php } ?>
<?php if (in_array('de', $langs) && in_array('en', $langs)) { echo '|'; } ?>
<?php if (in_array('de', $langs)) { ?>
 <a href="<?php echo htmlspecialchars(return_i18n_setlang_url('en')); ?>">english</a>
<?php } ?>
</div>

Everything is fine.
Just Im not sure how to set-up the default language?
Using this code my default becomes English and I want DE ..
Also how to setup classes for 'current' language ?

Thanx

Alex

Hello,

can someone help / advice me about my issue's ?

Thanx

Alex
Reply
Does anyone know how to to get custom fields in page navigation?
the code I have in mind is from here http://mvlcek.bplaced.net/get-simple/mul...av-pagenav
I need to show a custom field for previous and next page,
except I don't know how to do this with $nav[...][...]
like, $nav[...]['customfieldname'] doesn't work.
any ideas?
Reply
guys, can you please stop quoting your posts when you're responding just to previous one ? it's getting long and messy then...

@mvlcek, can you please check the bug I posted? http://get-simple.info/forums/showthread...4#pid52834
Reply
Hi,

First thank for this great plugin.

read a lot http://mvlcek.bplaced.net/get-simple/i18n

Is it posible witch languages/pages are present for make links on the page.

sample/idea :
If there is a language DE , EN and NL

echo the 3 links:
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url('de')); ?>">DE</a>
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url('en')); ?>">EN </a>
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url('nl')); ?>">NL</a>

So dependent on with languages/pages present.

Thank for comment
Reply
Is there a way to set top level menu and sub-menu as a two separate menus ?
Something like this

<nav id="main-menu" class="level-0">

<ul>
<?php get_i18n_navigation*blablabla; ?>
<li class="menu-item-has-children"><a href="about">About Us</a>
<ul class="sub-menu">
<?php get_i18n_navigation*blablabla; ?>
</ul>
</li>
<li><a href="<?php get_site_url(); ?>contacts">Contacts</a></li>
</ul>
</nav>

Original menu looks like this

<nav id="main-menu" class="level-0">

<ul>
<li><a href="<?php get_site_url(); ?>">Main</a></li>
<li><a href="<?php get_site_url(); ?>services">Services</a></li>
<li class="menu-item-has-children"><a href="about">About Us</a>
<ul class="sub-menu">
<li><a href="<?php get_site_url(); ?>reviews">Reviews</a></li>
</ul>
</li>
<li><a href="<?php get_site_url(); ?>contacts">Contacts</a></li>
</ul>
</nav>


The sub-menu slides with JavaScript to invisible area of the page
How to make this sub-menu working with this plugin?
Reply
(2015-09-20, 22:41:54)Frens Wrote: Is it posible witch languages/pages are present for make links on the page.

You can use return_i18n_available_languages() to get all available languages.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
(2015-09-21, 01:58:16)enri Wrote: Is there a way to set top level menu and sub-menu as a two separate menus ?

Yes, see e.g. http://mvlcek.bplaced.net/get-simple/mul...v-top-left.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
(2015-09-21, 03:39:07)mvlcek Wrote:
(2015-09-21, 01:58:16)enri Wrote: Is there a way to set top level menu and sub-menu as a two separate menus ?

Yes, see e.g. http://mvlcek.bplaced.net/get-simple/mul...v-top-left.

How do you think what is the better way to make a sub-menu that slides with JavaScript to invisible area of the page with your plugin?
Reply
(2015-09-21, 03:35:04)mvlcek Wrote:
(2015-09-20, 22:41:54)Frens Wrote: Is it posible witch languages/pages are present for make links on the page.

You can use return_i18n_available_languages() to get all available languages.

Thank for help 

I make :

PHP Code:
<a href="<?php echo htmlspecialchars(return_i18n_available_languages() ); ?>">test</a


dont now if this is the right, 
now got ONE link (with name test) , if have 4 different anguae pages . so need 4 links if is posible.

i can do 

PHP Code:
<div align="left">

<?
php $langs return_i18n_available_languages(return_page_slug()); ?>
<?php 
if (in_array('de'$langs)) { ?>
 <a href="<?php echo htmlspecialchars(return_i18n_setlang_url('de')); ?>">deutsch</a>
<?php ?>
<?php 
if (in_array('de'$langs) && in_array('en'$langs)) { echo '|'; } ?>
<?php 
if (in_array('de'$langs)) { ?>
  <a href="<?php echo htmlspecialchars(return_i18n_setlang_url('en')); ?>">english</a>
<?php ?>
</div> 

But when the user ad a new language/page , they must add/edit/delete code again in the theme.
When not posible , ik make al the posible languages in the condition as above
Reply
(2015-09-21, 04:20:38)Frens Wrote:
(2015-09-21, 03:35:04)mvlcek Wrote:
(2015-09-20, 22:41:54)Frens Wrote: Is it posible witch languages/pages are present for make links on the page.

You can use return_i18n_available_languages() to get all available languages.



Code:
<?php $languages = return_i18n_available_languages(); ?>
<?php foreach ($languages as $language) { ?>
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url($language)); ?>"><?php echo $language; ?></a>
<?php } ?>
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
(2015-09-21, 04:45:37)mvlcek Wrote:
(2015-09-21, 04:20:38)Frens Wrote:
(2015-09-21, 03:35:04)mvlcek Wrote:
(2015-09-20, 22:41:54)Frens Wrote: Is it posible witch languages/pages are present for make links on the page.

You can use return_i18n_available_languages() to get all available languages.



Code:
<?php $languages = return_i18n_available_languages(); ?>
<?php foreach ($languages as $language) { ?>
<a href="<?php echo htmlspecialchars(return_i18n_setlang_url($language)); ?>"><?php echo $language; ?></a>
<?php } ?>

Thnanks a lot  Mvlcek , works fine!
Reply
Hello, Im new here and my first post:

Im using this Internationalization (I18N) plug-in with a great success. Only I can not set-up the default language for the website.

Can someone help please this GS newbie ?

Regards ..
Reply
Hello, is it possible to place an item in the middle of the main links?
For example:

Main link 1
-- sub link 1
-- sub link 2
Main link 2

<HERE>

Main link 3
Main link 4

If we have an odd number of main links, the element will be on position n-1.
I have this effect now with Nested Menus, but I need to use multi language menu.

Please help Smile
Reply
Hello,

I'm using your plugins with great success but I would like to have 100% multilanguage support on my site... so my question is how should I translate elements like headers, paragraphs or other short texts that I know that will be static and never change? I wrote my own plugin with translations and function like 'function get_translation($field)' which gets me translation from lang folder for that plugin and displays on site. Unfortunately it seems to not work correctly after I change language on the frontend. Despite e.g. is set to - /?setlang=pl the texts appears to not change - only content that uses i18n by - get_i18n_component() function. Why it's not changed? It's not chaning because it takes language set by admin as a global not the one that user sets on his session? Could you help me with my question? Thanks!
Reply
(2015-09-28, 04:05:29)ghoscik Wrote: I'm using your plugins with great success but I would like to have 100% multilanguage support on my site... so my question is how should I translate elements like headers, paragraphs or other short texts that I know that will be static and never change? I wrote my own plugin with translations and function like 'function get_translation($field)' which gets me translation from lang folder for that plugin and displays on site. Unfortunately it seems to not work correctly after I change language on the frontend.

The I18n plugin sets the global variable $language. Make sure you use it in your plugin.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
Hi,

First of all thanks for your reply.

My "plugin" is rather simple... I thought this would be enough...:

PHP Code:
<?php
# get correct id for plugin
$thisfile=basename(__FILE__".php");

# add in this plugin's language file
i18n_merge($thisfile) || i18n_merge($thisfile'pl_PL');

# register plugin
register_plugin(
    
$thisfile,                                 # ID of plugin, should be filename minus php
    
i18n_r($thisfile.'/TITLE'),                     # Title of plugin
    
'1.0',                                     # Version of plugin
    
'XXX',                                    # Author of plugin
    
'XXX',                                 # Author URL
    
i18n_r($thisfile.'/DESC'),                     # Plugin Description
    
null,                                     # Page type of plugin
    
null                                     # Function that displays content
);

function 
get_translation($field) {

    
$pluginName 'XXX';

    return 
i18n($pluginName '/' $field);
}

?>


How should I use this $language variable in my code?
Reply




Users browsing this thread: 3 Guest(s)