multilang.inc.php
概要This plugin automatically tries to retrieve browser's language settings, and show only suitable contents. This page supports English and Japanese. 関連
ダウンロードYou may download the latest version from Subversion Repository. The version which is included in 1.4.5plus-u2-i18n is v0.4. You may also need to update lib/lang.php. If you are using 1.4.5plus-u2-i18n, this is necessary. 国旗画像If you do not have flag images, download from and place them into your IMAGE_DIR/icon/flags/ (IMAGE_DIR is defined in pukiwiki.ini.php, default is image/ ). 1.4.5plus-u2-i18n does not include this files as default. ConfigurationNow, languages you can use are only languages which are specified at $prepared_language at lib/lang.php. $language_prepared = array('ja_JP', 'zh_TW', 'zh_CN', 'en_US', 'ko_KR');
For examples, if you are deciding as you use only Japanese and English at your wiki site, you many modify as $language_prepared = array('ja_JP', 'en_US');
Let me assume nothing was shown when Korean language browsers accessed to your site because you were not preparing korean contents before. Then, this enables to show the contsnts of DEFAULT_LANG(e.g., en_US) when the Korean or other language browsers accessed. However, this disables to show Korean language menus which was shown before, and shows English menus instead. Now, it is difficult to add other languages. It is possible to add only languages which are prepared as system languages. 使い方Function 1: FilterWrite as below #multilang(en_US){{
This is English
}}
#multilang(ja_JP){{
これは日本語です
}}
&multilang(en_US){English!};&multilang(ja_JP){日本語!};
This plugin automatically try to retrieve browser's language settings, and show only contents of the language. You may use 'ja', 'en', 'ko', instead of 'ja_JP', 'en_US', 'ko_KR' respectively. Multi-language Examples #multilang(ja){{
*PukiWiki Plus! 日本語対応ページにようこそ! [#y302b3eb]
このソフトは、コンテンツネゴシエーションに対応しています。
ブラウザから得られる言語情報から自動でコンテンツを表示しています。
}}
#multilang(ko){{
*PukiWiki Plus! 한국 대응 페이지에 어서 오십시오! [#u209d6fc]
이 소프트는, 컨텐츠 네고시에이션에 대응하고 있습니다.
브라우저로부터 얻을 수 있는 언어 정보로부터 자동으로 컨텐츠를 표시하고
있습니다.
}}
#multilang(en){{
*PukiWiki Plus! Welcome to the page for English. [#x4ddf184]
This software corresponds to the contents negotiation.
Contents are displayed from language information obtained
from a browser by the automatic operation.
}}
#multilang(zh_TW){{
*PukiWiki Plus! 中文對應頁歡迎! [#z1cc77ea]
這個軟件,與內容negotiation對應著。從從瀏覽器能得的語言信息用自動表示著內容。
}}
#multilang(zh_CN){{
*PukiWiki Plus! 中文对应页欢迎! [#yc464217]
这个软件,与内容negotiation对应着。从从浏览器能得的语言信息用自动表示着内容。
}}
Tips When you want to use this plugin at Navigation, write as [http://ExternalLink &multilang(en){English};&multilang(ja){日本語};]
even if you want to link to inside of your pukiwiki site because pukiwiki now does not accept to use inline plugins with a link style as [[&multilang(en){English};&multilang(ja){日本語};>PukiWikiName]]
Function 2: Swithcer&multilang(link,en=English,ja=日本語); This creates links as above to change language settings, and it will save into cookie during the session (Usually till closing the browser). The left side of = is language, and right side is a label. As default, this shows flag images which are located at IMAGE_DIR/icon/flags/ (IMAGE_URL is defined at pukiwiki.ini.php). In this case, labels are used for title, alt attributes of img tag. Used image files are guessed from langague settings (ja_JP -> jp.png, ja -> ja_JP -> jp.png). &multilang(link,en,ja); Yes, you may omit labels, but I recommend you to specify titles in terms of HTML style. &multilang(link,en=English+text,ja=日本語+text); // text If you do not like to use flag images, you may use text option as above. &multilang(link=delim,en=English+text,ja=日本語+text); // delim Option delim shows delimiters such as [, |, and ]. You can modify the delimiters in this plugin file. Rather, you may call as [ &multilang(link,en=English+text); | &multilang(link,ja=日本語+text); ] then, you can change delimiters easier. I might've not needed to create delim option.... &multilang(link,en=English+flag,ja=日本語+text); // clear to use flag You can make it clear to use flag images with flag option. It is default behavior. &multilang(link,en=English+flag=jp,ja=日本語+flag=us); // specify flag file You can specify flag images. The URL will be like 'IMAGE_URL/icon/flags/us.png'. I recommend you to place this on MenuBar or SideBar (extention of Pukiwiki Plus). |