By grassdog on
Dear all,
I have installed the correct language set(chinese), but what I want is to have two language version for my site, the user may click a link to switch between the two languages.
How to do it properly?
Thanks a lot!
xing
Comments
Multilingual sites infrastructure - language direction
Hi Xing,
Take a look at the Drupal's internationalization (I18N) module - it supports multiple versions of the same page, with languages, so if you display Chinese in an left-to-right direction, like English, it may suffice.
But is Chinese a special case? Hebrew, my language, is displayed right-to-left. Which Chinese script are you talking about? And what's it's direction? is it left to right, like English? or top to button?
To correctly support Hebrew, Arabic, and other languages with non-standard direction we should add a 'direction' attribute to the 'language' table on the drupal core. The values of this table may be taken from the full W3C languages direction table. Then, we may add a switch which loads a little extension to 'drupal_[direction].css' which load the correct definitions of the direction, according to the language. For example, for Hebrew and Arabic we may load 'drupal_rtl.css' since the direction is RTL.
Next, as an extra optional step, we may add a little switch to the phptemplate engine, which dynamically loads an extra theme-specific style file (which may be called style_[direction].css - e.g. style_rtl.css) according to the language chosen by the user.
Go on and implement it! I have now opened the language direction support as a feature request.
All the best,
Amnon
-
Drupal Israel- Hebrew drupal translation project.
New 'direction' field - new 'locale' module issue
I've opened the new direction field as an issue for the 'locale' core module : http://drupal.org/node/56110. The style switching seems like the responsibility of the internationalization module.
Multilingual
Ni Hao!
Assuming you are using locales, you can get the user language via:
$languages = (function_exists('locale')) ? locale_supported_languages() : array('name' => array());
if ($user->language == '') {
$user->language = key($languages['name']);
}
The $user->language [name] variable has the language if the user is signed in, if not we force it from the language list.
I'm not sure how to set the current language - probably something like set the $user -> language explicitly.
I'm working on this at the moment - looks like the best way is to override the php_template variables - this is described in
http://www.lullabot.com/articles/hacking_phptemplate
I've posted some sample code in there for language selection for theming. I haven't tried it yet, but it should be fairly straightforwards to do the same thing for changing the current language.
I'll post back here if I get my version working before you reply :)
Cheers,
Lawrence / 小杜
-=-=-=-=-=-=-=-=-=-=-=-=-=-=
http://www.shanghaiguide.com