GetSimple Support Forum
Support for multilanguage sites, Internationalization (I18N) - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Plugins (http://get-simple.info/forums/forumdisplay.php?fid=13)
+--- Thread: Support for multilanguage sites, Internationalization (I18N) (/showthread.php?tid=1221)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43


RE: Support for multilanguage sites, Internationalization (I18N) - xuser - 2015-08-05

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???);


RE: Support for multilanguage sites, Internationalization (I18N) - revotron - 2015-08-07

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


Anyone? Big Grin


RE: Support for multilanguage sites, Internationalization (I18N) - Angryboy - 2015-08-08

(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.


RE: Support for multilanguage sites, Internationalization (I18N) - shawn_a - 2015-08-09

it also escapes xss injections


RE: Support for multilanguage sites, Internationalization (I18N) - revotron - 2015-08-14

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.


RE: Support for multilanguage sites, Internationalization (I18N) - morvy - 2015-08-21

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


RE: Support for multilanguage sites, Internationalization (I18N) - alex_d - 2015-08-24

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


RE: Support for multilanguage sites, Internationalization (I18N) - vallhund - 2015-08-31

(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


RE: Support for multilanguage sites, Internationalization (I18N) - vallhund - 2015-08-31

(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


RE: Support for multilanguage sites, Internationalization (I18N) - alex_d - 2015-08-31

(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


RE: Support for multilanguage sites, Internationalization (I18N) - moonspider - 2015-09-02

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/multi-level-navigation/nav-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?


RE: Support for multilanguage sites, Internationalization (I18N) - morvy - 2015-09-02

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.php?tid=1221&pid=52834#pid52834


RE: Support for multilanguage sites, Internationalization (I18N) - Frens - 2015-09-20

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


RE: Support for multilanguage sites, Internationalization (I18N) - enri - 2015-09-21

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?


RE: Support for multilanguage sites, Internationalization (I18N) - mvlcek - 2015-09-21

(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.


RE: Support for multilanguage sites, Internationalization (I18N) - mvlcek - 2015-09-21

(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/multi-level-navigation/nav-top-left.


RE: Support for multilanguage sites, Internationalization (I18N) - enri - 2015-09-21

(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/multi-level-navigation/nav-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?


RE: Support for multilanguage sites, Internationalization (I18N) - Frens - 2015-09-21

(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


RE: Support for multilanguage sites, Internationalization (I18N) - mvlcek - 2015-09-21

(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 } ?>



RE: Support for multilanguage sites, Internationalization (I18N) - Frens - 2015-09-21

(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!


RE: Support for multilanguage sites, Internationalization (I18N) - Akyba - 2015-09-21

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 ..


RE: Support for multilanguage sites, Internationalization (I18N) - bakal - 2015-09-25

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


RE: Support for multilanguage sites, Internationalization (I18N) - ghoscik - 2015-09-28

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!


RE: Support for multilanguage sites, Internationalization (I18N) - mvlcek - 2015-09-28

(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.


RE: Support for multilanguage sites, Internationalization (I18N) - ghoscik - 2015-09-28

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?