Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Support for multilanguage sites, Internationalization (I18N)
shawn_a Wrote:I wrote a custom rendering component for twitter bootstrap nav bars and dropdowns.

I need to know what the $show parameter was when the component is called.
Is there anyway to get this, or can you pass it in as an object parameter with item ?

If you only need to know whether to show titles or menu texts, there is the attribute showTitles.
Otherwise you could either use different components or you can store the parameter in a global variable.
E.g. template:
Code:
...
<?php
global $myshow;
$myshow = I18N_SHOW_NORMAL;
get_i18n_navigation(return_page_slug(),0,0,$myshow,'mycomponent');
?>
...
and component mycomponent:
Code:
<?php
global $myshow;
if ($myshow & I18N_FILTER_MENU) {
...
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
mvlcek Wrote:
shawn_a Wrote:I wrote a custom rendering component for twitter bootstrap nav bars and dropdowns.

I need to know what the $show parameter was when the component is called.
Is there anyway to get this, or can you pass it in as an object parameter with item ?

If you only need to know whether to show titles or menu texts, there is the attribute showTitles.
Otherwise you could either use different components or you can store the parameter in a global variable.
E.g. template:
Code:
...
<?php
global $myshow;
$myshow = I18N_SHOW_NORMAL;
get_i18n_navigation(return_page_slug(),0,0,$myshow,'mycomponent');
?>
...
and component mycomponent:
Code:
<?php
global $myshow;
if ($myshow & I18N_FILTER_MENU) {
...

I guess that works, I was trying to do it dynamically for ease of use for users of that theme. But i guess if they need to touch the code they can do a work around also or I can write my own wrappers for all the functions or rethink how i am doing this. (bootstrap doesn't have dual function drop downs by default, you cant click on the title OR a dropdown, its only dropdown. So I was doing it click if normal and dropdown only, if menu OR isopen so you get the dropdown after clicking the menu item on its page when its current and open.

sorry for rambling, Ill probably post all details on this somewhere more relative lol.

Thanks for the ideas, I was code blinded at the time.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
I know I am nitpicking with this idea.
@mvlcek
Did you ever consider moving this setting and the text associated to a separate page in the admin? Such as an I18N settings page in order to keep the admin UI simple and free of clutter? Just a suggestion. Smile
Todo arde si le aplicas la chispa adecuada.
Reply
yurifanboy Wrote:I know I am nitpicking with this idea.
@mvlcek
Did you ever consider moving this setting and the text associated to a separate page in the admin? Such as an I18N settings page in order to keep the admin UI simple and free of clutter? Just a suggestion. Smile

GS before 3.1 did not support multiple side bar menu items per plugin file (which is why the I18N plugin consists of two plugin files, i18n_base.php and i18n_navigation.php).
(although in the mean time I've found ways to circumvent this limit)

As I want to keep the compatibility to 3.0 (and have lot's of other plugins) I don't know if and when I will have time for it.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
I18N version 3.0.2:
  • just corrects a display problem in Safari/Chrome (@rpetges, @shawn_a)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
mvlcek Wrote:I18N version 3.0.2:
  • just corrects a display problem in Safari/Chrome (@rpetges, @shawn_a)

Thanks for the update ! Much appreciated.

Romain
Reply
Mvlcek: do you have an idea how could I prepare a translation file/files and use them in templates to label frontend items ? Because using conditionals like
Code:
<?php if ($language == 'en') { ?>English text<?php } ?>
in N languages for static links/images/etc. becomes difficult in long term.

I remember that somebody asked for such thing on forums, but I can't find this post.
Addons: blue business theme, Online Visitors, Notepad
Reply
yojoe Wrote:Mvlcek: do you have an idea how could I prepare a translation file/files and use them in templates to label frontend items ? Because using conditionals like
Code:
<?php if ($language == 'en') { ?>English text<?php } ?>
in N languages for static links/images/etc. becomes difficult in long term.

I remember that somebody asked for such thing on forums, but I can't find this post.

If you have only a few places in the template, like header/title, sidebar, footer, you can use components (with language suffix _xx for non-default languages) and get_i18n_component for the language specific parts.

If you need it for special pages (i.e. I18N Special Pages plugin), the plugin allows you to use different content/searchresult templates for each language.

Another simple solution would be to set a map with all strings in the top of your template and then access the map for the strings, e.g.
Code:
<?php if ($language == 'en') {
  $text = array('title' => 'My title', 'size' => 'Size');
} else if ($language == 'de') {
  $text = array('title' => 'Mein Titel', 'size' => 'Größe');
} else {
  # default language polish...
} ?>
...
<?php echo $text['title']; ?>

Another way would be to create a dummy plugin which uses the GS API for internationalization and just sets the language on a hook. You would use
Code:
<?php i18n('mytextplugin/title'); ?>
in your template. Then you can use the Translate plugin to translate the texts.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
mvlcek Wrote:Another simple solution would be to set a map with all strings in the top of your template and then access the map for the strings
...
Another way would be to create a dummy plugin which uses the GS API for internationalization and just sets the language on a hook .
Brilliant !
I'll play try those two ways, as they seem to be the most flexible ways.
Thanks for the hundredth time.
Addons: blue business theme, Online Visitors, Notepad
Reply
FYI, some things I noticed with your plugins.

Your javascript for hiding the pages sidemenus is active on all pages not just pages page.

Also your not using createsidemenus or nav tab for sidemenus and tabs which might cause your plugin to break if we make changes to core. For example the new sidemenu and tab classes that we added to those menus.


oh and if you change your sidemenu hooks to register on front end also , they will work with my adminbar plugin automatically.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
shawn_a Wrote:FYI, some things I noticed with your plugins.

Your javascript for hiding the pages sidemenus is active on all pages not just pages page.

I'll change it - any problems with this so far?

shawn_a Wrote:Also your not using createsidemenus or nav tab for sidemenus and tabs which might cause your plugin to break if we make changes to core. For example the new sidemenu and tab classes that we added to those menus.

Naturally, as those functions did not exist with this functionality before GS 3.1 and were updated/created based on my code in 3.1. I'll try to detect GS 3.1+ and use the native functions.

shawn_a Wrote:oh and if you change your sidemenu hooks to register on front end also , they will work with my adminbar plugin automatically.

Oh god, I optimize my plugins as best as possible and then a certain individual creates an adminbar plugin... ;-)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
hehe

No issues that I noticed, just saw the javascript when debugging other stuff.

I figured those were a 3.0 compat thing, since its an exact copy of the core functions.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
2 more minor things

On the view all pages page.
You have a checkbox for toggle status, with a em on the u, but that accesskey doesn't work.

As opposed to this which is in core and works and looks alot better.
Code:
<a href="#" id="show-characters" accesskey="u" class="">Toggle Stat<em>u</em>s</a>
aka
Code:
<a href="#" id="show-characters" accesskey="<?php echo find_accesskey(i18n_r('TOGGLE_STATUS'));?>" ><?php i18n('TOGGLE_STATUS'); ?></a>

Another 3.1 feature introduction perhaps ? was added in r456 it seems.

And the other one.
You are using X instead of &times; for delete characters, so it doesn't match cores appearance.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
shawn_a Wrote:You are using X instead of &times; for delete characters, so it doesn't match cores appearance.
If your plugins were on github I would have patched and pr'ed this for all of your plugins months ago.
Modern UI Admin for GetSimple
Watch the demo. Install this plugin. Use this CSS. Enjoy.
Reply
I was doing an install in a sub-folder earlier today for a client, to test if everything would work properly with their hosting partner.

Had debug mode switched on and upon creating a new page and saving it the following notice appeared:

Code:
Notice: Undefined index: existing-url in /var/www/vhosts/kadekraankampen.nl/httpdocs/test/plugins/i18n_base/sitemap.class.php on line 126

Notice: Undefined index: existing-url in /var/www/vhosts/kadekraankampen.nl/httpdocs/test/plugins/i18n_base/sitemap.class.php on line 129
Error: Headers already sent in /var/www/vhosts/kadekraankampen.nl/httpdocs/test/plugins/i18n_base/sitemap.class.php on line 126 If your browser does not redirect you, click here

Doesn't appear when debug mode is switched off by the way.

Didn't notice this notice before. Any idea what is causing it? Conflict between the i18n plugin and 3.1.2 perhaps?
Reply
How does this plugin work with Google Analytics?

I'm building a site in both English and French.

It the full URL is shown, I assume the variable "lang=fr" will show up in the Analytics report.

But if Fancy URLs is selected, then the URLs are the same for each page irregardless of the language of the content.

Does Google still differentiate the pages somehow or is there something I need to set to alert Google which language the viewer is seeing?
Reply
Ed at ISI Wrote:How does this plugin work with Google Analytics?

I just ran some tests. As one might suspect, Google goes by what the URL says and can't tell the difference between one language and another.

Even with "Fancy URLs" turned off, the variable "lang=fr" only shows up for the first page viewed. The rest still show the same URL as the English.

I'm not sure how to resolve the issue of tracking the languages separately without getting convoluted.

Maybe abandon the Google Analytics plugin and put in the raw Google tracking code with an if/then statement.... if English, use this Tracking ID, if French, use this other one. I don't know if Google is good with that scheme, though. Two tracking IDs, one website.

Does anyone have an easier idea?
Reply
Ed at ISI Wrote:Maybe abandon the Google Analytics plugin and put in the raw Google tracking code with an if/then statement.... if English, use this Tracking ID, if French, use this other one. I don't know if Google is good with that scheme, though. Two tracking IDs, one website.

Exploring Google's documentation, they are not cool at all on the above scheme.

I did discover that they track what language the user's browser is set at but that's not quite the same thing.
Reply
Ed at ISI Wrote:How does this plugin work with Google Analytics?

I'm building a site in both English and French.

It the full URL is shown, I assume the variable "lang=fr" will show up in the Analytics report.

But if Fancy URLs is selected, then the URLs are the same for each page irregardless of the language of the content.

Does Google still differentiate the pages somehow or is there something I need to set to alert Google which language the viewer is seeing?

If you use get_i18n_header() instead of get_header(), the plugin will include a canonical link with the language in the header. At least Google indexes both language versions of my few multi language pages on http://mvlcek.bplaced.net. You can also configure the plugin to put the language at the end of the URL instead of into the lang parameter.

Or you can configure the plugin to always include the language in the URL.

For more information see the (now updated) page http://mvlcek.bplaced.net/get-simple/i18n/.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
mvlcek Wrote:get_i18n_header

Sweet.

I knew there had to be an easy way.

Thank You, Sir. Your work is highly appreciated.
Reply
Notice: Undefined index: existing-url in /var/www/vhosts/kadekraankampen.nl/httpdocs/test/plugins/i18n_base/sitemap.class.php on line 126

Notice: Undefined index: existing-url in /var/www/vhosts/kadekraankampen.nl/httpdocs/test/plugins/i18n_base/sitemap.class.php on line 129
Error: Headers already sent in /var/www/vhosts/kadekraankampen.nl/httpdocs/test/plugins/i18n_base/sitemap.class.php on line 126 If your browser does not redirect you, click here


Error!!!
3.1.2
Reply
libygo Wrote:Notice: Undefined index: existing-url in /var/www/vhosts/kadekraankampen.nl/httpdocs/test/plugins/i18n_base/sitemap.class.php on line 126

I'll look into it for the next version.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
Mvlcek: did you think about adding multiple menus feature ?
The way I'd see it would involve an additional dropdown in page's option to choose menu ID, xml tag in page's file, and a bit of programming magic - as a matter of course Wink
Addons: blue business theme, Online Visitors, Notepad
Reply
trying to debug a site not working, i found this in errolog.txt:

[25-Jul-2012 20:06:27] PHP Fatal error: Call to undefined function nm_list_recent() in /var/www/sitename.com/plugins/i18n_base/frontend.class.php(127) : eval()'d code on line 16

using GS 3.12. Setting debug to on i get no error output, so i suppose this is not a major bug.
Reply
marrco Wrote:trying to debug a site not working, i found this in errolog.txt:

[25-Jul-2012 20:06:27] PHP Fatal error: Call to undefined function nm_list_recent() in /var/www/sitename.com/plugins/i18n_base/frontend.class.php(127) : eval()'d code on line 16

using GS 3.12. Setting debug to on i get no error output, so i suppose this is not a major bug.

Nothing to do with I18N: You include a component (via get_i18n_component, but would be the same with get_component), which calls the (News Manager plugin) function nm_list_recent, but News Manager is either not installed or disabled.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply




Users browsing this thread: 5 Guest(s)