With this plugin you can have a text in multiple languages. Easy to use, no requirements.
Just tag parts of your text to be in different languages, and a flag will appear next to the text and allows users to switch between them.
No other elements of the blog will be translated.
Use [:gb]
to specify that the following text part is english, or use any other two char language code.
To use one text block in multiple languages use e.g. [:gb,de]
, which is handy for parts like images.
Write [:*]
to use the block in all (within the text already known) languages.
You can without any problem mix many of those tags. e.g. [:gb]english-intro[:de]german-intro[:*]common image[...]
.
Optionally also the title of a text can be multilingual, but requires theme modification.
The flags can be placed:
Thanks to:
You may overwork the readme and also the other texts… that would be great.
If you have ideas/bugs please contact me.
The package also contains an version for PHP5.3+. The file is functional identical to the other one (which only requires PHP 5.2) but makes usage of a nice new feature and is easier to read/write.
When WordPress requires PHP5.3+ (sometime in the future) that file will be used.
The flags are from http://www.free-country-flags.com/ and under CC-BY-SA License (http://creativecommons.org/licenses/by-sa/3.0/).
Requirements:
Installation:
/wp-content/plugins/
directoryFlags (optional):
Theme Modifications (optional):
<?php Multilingual_Text::Flags(); ?>
in front of the title, or where you like to have the flags<?php the_title(); ?>
with <?php Multilingual_Text::Title(); ?>
, this can’t be done automatically because some titles (like the <title>
or other <meta>
elements) do not support switchingWidget (optional):
Custom usage:
Multilingual_Text::Parse(string $text [, bool $with_flags = true [, bool $with_text = true ]] )
will parse the text (ml-style) and returns the generated code.$with_flags
and $with_text
you can control wether flags and/or text will be returned.echo
it – or process it anyway.The first matching will be picked:
In the system default language.
Bots (everything with a “bot” in the user agent) will see a different page:
Maybe this is not perfect, please mail me if you know a better way.