Drupal7做一个双语站
来源:互联网 发布:生活中的人工智能产品 编辑:程序博客网 时间:2024/04/28 15:57
本文主要讲解Drupal7做一个双语站:简体中文、英文。方法同样可以应用在Drupal6和Drupal8。
步骤
1)建立一个Drupal站点的启用Locale 和 Content translation module模块。
2)配置Drupal站点支持多语言,包括三种语言中文简体,中文繁体,英语(默认)。
3)配置语言检测,激活检测方法“浏览器”(检测我的浏览器的语言设置的优先语言)。
4)改变Firefox如何发送Accept-Language header头部信息。进入“首选项”,“内容”选项卡,然后在“选择…”按钮,通过“选择您显示页面的首选语言”。
5)确认,语言能正确的检测到英语,并正确的使用英语显示页面,当使用英语作为默认的Accept-Language Header。
请求报头(Accept-Language 为en-us)
GET / HTTP/1.1Host: www.lixiphp.comUser-Agent: Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.7.1Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-us,en;q=0.5Accept-Encoding: gzip, deflateCookie: has_js=1; __utma=160924194.585573359.1364388874.1364388874.1364388874.1; __utmb=160924194.21.10.1364388874; __utmc=160924194; __utmz=160924194.1364388874.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); Drupal.tableDrag.showWeight=0x-insight: activateConnection: keep-aliveIf-None-Match: "1364390561"
响应报头(自动跳转到http://www.lixiphp.com/en英语路径)
HTTP/1.1 301 Moved PermanentlyServer: nginx/0.8.49Date: Wed, 27 Mar 2013 13:23:00 GMTContent-Type: text/htmlTransfer-Encoding: chunkedConnection: keep-aliveKeep-Alive: timeout=20X-Powered-By: PHP/5.2.9Expires: Sun, 19 Nov 1978 05:00:00 GMTCache-Control: no-cache, must-revalidate, post-check=0, pre-check=0Etag: "1364390579"Location: http://www.lixiphp.com/en
6)确认,语言能正确的检测到简体中文,并正确的使用简体中文显示页面,当使用简体中文作为默认的Accept-Language Header。
请求报头(Accept-Language 为zh-cn)
GET / HTTP/1.1Host: www.lixiphp.comUser-Agent: Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.7.1Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: zh-cn,en-us;q=0.7,en;q=0.3Accept-Encoding: gzip, deflateCookie: has_js=1; __utma=160924194.585573359.1364388874.1364388874.1364388874.1; __utmb=160924194.22.10.1364388874; __utmc=160924194; __utmz=160924194.1364388874.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); Drupal.tableDrag.showWeight=0x-insight: activateConnection: keep-aliveIf-None-Match: "1364390579"
响应报头(自动跳转到http://www.lixiphp.com/zh-hans简体中文路径)
HTTP/1.1 301 Moved PermanentlyServer: nginx/0.8.49Date: Wed, 27 Mar 2013 13:29:37 GMTContent-Type: text/htmlTransfer-Encoding: chunkedConnection: keep-aliveKeep-Alive: timeout=20X-Powered-By: PHP/5.2.9Expires: Sun, 19 Nov 1978 05:00:00 GMTCache-Control: no-cache, must-revalidate, post-check=0, pre-check=0Etag: "1364390977"Location: http://www.lixiphp.com/zh-hans
7)添加“语言切换器(用户界面文本)”区块在头部
如果需要一些修饰,可以在语言前面加上国旗,最后就会得到:
演示与说明
演示地址:http://www.lixiphp.com
如果你的浏览器默认是简体中文,自动会跳转到http://www.lixiphp.com/zh-hans
页面内容为:
欢迎光临 LixiPHP
首页无内容!
如果你的浏览器默认是英文,自动会跳转到http://www.lixiphp.com/en
页面内容为:
Welcome to LixiPHP
No front page content has been created yet.
赶紧入手尝试一下Drupal建立一个双语站吧!
- Drupal7做一个双语站
- 双语美文:我想! 我做! 我得到!
- 写一个Drupal7有关SEO的小模块
- drupal7 创创建一个菜单项的数组参数
- drupal7(6) 代码方式登录一个用户 加验证
- drupal7 services
- drupal7翻译
- drupal7安装
- drupal7安装
- Drupal7分页
- Drupal7 安装
- 在drupal7中创建一个表时,如何让主键自动增长
- 就这一个链接让你搞懂drupal7的hook
- drupal7 如何将一个date字段添加上日期插件效果
- 做一个弱者,站在巨人肩上。
- 建站教程,如何做一个网站!
- 谈谈是多做站好还是做一个站好
- 一个菜鸟做站三个月的心得体会
- POJ 3525 Most Distant Point from the Sea 二分+半平面交
- Android Layout
- 第5周作业-打字成绩判断程序
- 春季养生食谱 灵芝孢子粉牛排汤补中益气
- 剑指offer:单链表的基本操作
- Drupal7做一个双语站
- js 技术自学
- vss(2005)使用详解
- fopen\fread\fwrite\fscanf\fprintf\fseek\feof\rewind\fgets\fputc等系列函数使用总结
- 工厂模式
- 单词分割
- 一个合格的程序员应该读过哪些书
- 好开心哦
- POJ 2612 Mine Sweeper 模拟