xLanguage (Wordpress Plugin)
Monday, January 21st, 2008
完全使用手冊 (1)
This page focuses on the general usage and xLanguage configuration, while the next page will focus on the code modifying and APIs so to make everything work as a whole.
How to Use
The basic usage is already shown in the options page. One should first added some languages in the options page. Then one can use the toolbar which is available in the rich text editor to tag the text. For single line content, please adopt the single line filtering mode syntax.
Composing Hotkey
You can use Ctrl+Alt+1 (or 2, 3, etc…) to tag the highlighted text or whole paragraph as in the first (second, third, etc) language. Ctrl+Alt+0 to remove the tag. This should come very handy for keyboard-hotkey-lover like me. Last but not least, Ctrl+Alt+Shift+0 (or Ctrl+Alt+` for pre-WP2.5) to toggle the highlight mode.
Display Filtering
To hide all the posts, pages written in foreign language that reader cannot read, you should-
- Go to the Advanced page. Under Display Filtering section, enable this options.
- Rebuild the metadata index after enabling it. Otherwise it will has no effect over the existing post. It takes a few screen flickers if you have more than hundreds of posts.
- From now on if you perform further language related operation (like Add/Remove and Mix & Match), you should rebuild this index to reflect the latest changes, as reminded by the result confirmation.
- Note that you don’t have to rebuild the index for day to day operation like posting and editing.
Language Configuration
Simple binary bilingual configuration
Example: Blog in English and Spanish, while English being the primary.
- Add two languages.
- Code: en, Name: English
- Code: es, Name: Español
- Set en as default.
- Optionally add fallback for both language in the advanced page. i.e. en fallbacks to es, es fallbacks to en, with appropriate message.
- Done. Start blogging with two languages.
Biligual configuration with overlapping
Example: Chinese and a localized Chinese dialect like Cantonese. Cantonese reader can read Chinese but general Chinese reader cannot read Cantonese. Blog is mainly done in Chinese, and the page title, tags and categories are only written in Chinese.
- Add three languages.
- Code: xx-zh, Name: ”
- Code: zh, Name: Chinese
- Code: zh-yue, Name: Cantonese
- Set zh as default.
- In advanced page, do the following modification under the Mix & Match section
- xx-zh — Show: ”, Available As: ‘zh,zh-yue’, Position: 0
- zh — Show: ‘xx-zh,zh’, Available As: ‘zh’, Position: 0
- zh-yue — Show: ‘xx-zh,zh-yue’, Available As: ‘zh-yue’, Position: 0
- Optionally add fallback for the languages in the advanced page.
- Done. Start blogging. You may or may not tag the content with xx-zh when blogging, but would be useful if you upgrade to triligual later.
Triligual configuration with overlapping
Example: Blog in Chinese, a localized Chinese dialect like Cantonese and English. Cantonese reader can read Chinese but general Chinese reader cannot read Cantonese. Blog is mainly done in Chinese, and the page title, tags and categories are only written in Chinese and English. (Just like this blog!)
- Add four languages.
- Code: xx-zh, Name: ”
- Code: zh, Name: 中文|Chinese
- Code: zh-yue, Name: 粵語|Cantonese
- Code: en, Name: English
- Set zh as default.
- In advanced page, do the following modification under the Mix & Match section
- xx-zh — Show: ”, Available As: ‘zh,zh-yue’, Position: 0
- zh — Show: ‘xx-zh,zh’, Available As: ‘zh’, Position: 0
- zh-yue — Show: ‘xx-zh,zh-yue’, Available As: ‘zh-yue’, Position: 0
- en — Show: ‘en’, Available As: ‘en’, Position:1
- Optionally add fallback for the languages in the advanced page.
- Done. Start blogging. For Chinese content, tag the content with xx-zh. Or zh and zh-yue if you have written separated content for them.
Fallback and Mix & Match
One might ask in the overlapping example given above, why do we need an additional language xx-zh when zh-yue can be fallback to zh and vice versa. The reason is that, if a zh-yue user is reading a xx-zh post, no “zh” options will be shown in the xlanguage_post_other_langs() bar, but if you only relies on fallback, and did the post in zh, the same function will show the zh available as “other_langs”.
Search Engine Optimization
It might be beneficial to present a page with all content to the search engine crawler, so all your content are identified to be under one URL, instead of a few URL diluting the Google PageRank. And this can be done too!
- Add a third language, with locale code like ‘all’ (or anything that won’t collide with any other potential code in the world). Set it to be the Search Engine default.
- In the Advanced page, make the ‘all’ language only available to the Search Engine under Presentation section
- Under Mix & Match, for the language ‘all’, list all your languages in the ‘Show’ field, list nothing (empty) in the ‘Available As’, and set -1 in the ‘Position’.
- Now it’s done. You might try it out by modifying one of your User Agent string to a crawler one, such as ‘googlebot/1.0′. Firefox’s User Agent Switcher can take care of this task easily.
Beware that the search engine crawlers are recognized by using the reported User Agent line only, the detection logic is prone to have false positive though chance might be small (Actual User recognized as Search Engine).
After weighting the tradeoff, you might want to mark all the other languages to be not available to Search Engine to reduce duplicated content, by-
- In the Advanced page, under Presentation, uncheck the availability of Search Engine of those non-all themes.
- Verify again with your browser.
Permalink modification, Postfix or Prefix
If you have the Permalinks feature enabled in WordPress (Settings -> Permalinks), and I don’t see any reason why you don’t unless it’s not supported by your host, the language specifier would then appear as part of the link like …/lang/en, instead of in the form of query string “?lang=en”.
Since v1.3.0, You then have the choice to place the specifier at the beginning of the link (the Prefix mode), or the end of the link. (the Postfix mode). The prefix mode is the default for new installation, and presumably should work nicer with other plugins if you ever run into problem. It also looks better and more intuitive. However, it’s a new feature and if you have encountered any bugs due to this, please do let me know.
Parser (XHTML or Square Bracket)
Since v1.1.0, there are two parsers provided so that your content could be tagged in either way to have it recognized and extracted. Personally I prefer XHTML parser, which <span lang=”..”> works great and incorporate with the standard nicely, while Square Bracket (SB) use [lang_...]…[/lang_...] to tag the content, works equally good when XHTML is not an option. Here is the list showing how they are different besides the tagging code used—
- The XHTML parser uses HTML tag to tag the content, such that the code is not visible to the user and editor, as well as to the WP searching functionality.
- The XHTML parser requires strict XHTML to work on, otherwise the parser will fail and complain. Some plugins are known to generate invalid XHTML content that can mess up the parse. The SB parser does not have this problem.
- The XHTML parser relies on the XML parsing provided by PHP, which might not be installed at all. If that’s the case, SB is your only choice.
- The XHTML parser implementation is very sensitive to the actual PHP-XML parser implementation, which render it not working in untested PHP version. The SB parser is much more stable in this aspect.
- The XHTML parser can parse nested language tag, while the SB parser does not work with nested the SB tag.
- In composing mode, the toolbar for XHTML parser have better functionality such as highlighting (in Firefox and IE7 only), and set/unset function.
Currently, if the XHTML parser failed, the cause will be logged in the Parser Log. Please check the log from time to time to see which page is causing the problem.































































中文
粵語
January 8th, 2009 at 1:35
Hi Raúl. No there is no way to remove /lang/ yet, but this is surely one of the most popular requests and I am listening.
Category and tag: use the single line mode, like how you write post title. that is, separated by |. Use single line mode on the “Name”, while keeping using simple english for the “Slug”. For posting under new tag, please tag your post with a correct slug first then go back to the management interface to modify the name into multilanguages.
January 8th, 2009 at 1:27
Hi Sam!
First off all, regards for the plugin.
I’m trying to get rid easily from that ugly “/lang/” in the permalinks. Can you help?
Also I’ve found nothing in the usage guide refering to categories or tags. How can i define the language for those?
Many thanks in advance and best regards.
PS.: Don’t you have a forum or something where to support?
January 7th, 2009 at 7:20
Hello Dear Sam,
Please don’t forget about me… I’m still struggling with the _ES -es thing (see comment #348 above). Is there something I can do to help solving this? I’ve seen some people having the same problem.
THANKS A MILLION!
January 7th, 2009 at 5:57
Hi Sam,
I’ve noticed a problem after upgrading to WP 2.7 and unfortunately xLanguage 2.0.1 doesn’t solve it: on my blog front page I have links to the various language versions (<a href=”/lang/en”> et cetera) and clicking them now says 404 not found!
A workaround was to go to xLanguage’s preferences and change permalink style from prefixing to postfixing. For me it’s not really a big issue. However, due to the warning about postfixing not working with paged comments and other plugins, and because other users upgrading will likely see this I thought you would like to know..
January 7th, 2009 at 4:50
Ooops, writing my mail and seeing your mail again I figured out that I have to rename my files to de-de.png, de-de-active.png sorry etc. now it works thanks!
January 7th, 2009 at 4:45
Hi Sam,
well for example the german flag is here: http://www.yogie.de/wp-content/themes/yogie-mod/view/xlanguage/images/de.png and there is also de-active.png, en.png and en-active.png.
In my settings I use de-de and en-us as locale codes…
How should the permissions of the images look like?
January 7th, 2009 at 4:23
Andy: sorry I (half accidentally half intentionally) changed the default template.
Please use the old template to restore the previous look and feel.
The template of the previous version could be downloaded at http://plugins.trac.wordpress.org/browser/xlanguage/tags/1.3.3/view/xlanguage
Put it (other_post_lang.php) into /wp-content/themes/_YOUR_THEME_/view/language (create the folder as needed)
Louis: Removing the /lang/ this is not possible just yet. Stay tuned.
Yogie: Please do me a flavor in checking a few things. 1. The filename is correct, “xx” is corresponding to your language code, and it is CASE Sensitive. 2. The files are uploaded with correct permission. For example, here is my files structure under /themes/.
hellosam1/view/xlanguage/images
hellosam1/view/xlanguage/images/en-active.png
hellosam1/view/xlanguage/images/en.png
hellosam1/view/xlanguage/images/zh-active.png
hellosam1/view/xlanguage/images/zh-hk.png
hellosam1/view/xlanguage/images/zh.png
hellosam1/view/xlanguage/images/zh-hk-active.png
January 6th, 2009 at 23:26
Hello,
First, thanks for for this good and really extensive plugin !
I’d like to know how I can delete le word “lang” in my url,
to have this
http://www.example.com/fr/date/post
instead of this
http://www.example.com/lang/fr/date/post
Thanks
January 6th, 2009 at 22:38
Well to me simply adding the xx.png and xx-active.png files will not work
I added them into /wp-content/themes/”mytheme”/view/xlanguage/images/ and also into the plugin folder - No Success!
January 6th, 2009 at 21:48
Hi again.
I have had a bit of time to re-read your new instructions for installation and have discovered that I had to recreate the view/images folder inside my theme. This now works to show the flags (but the flags only) whereas before it showed “[flag] Other language name” etc.
Where can I add the code so I can show the language name and the flag?
thanks,
Andy