如何根据域默认使用另一种语言
我正在使用 Joomla 和 JoomFish 翻译组件。该网站有德文和中文翻译。我想弄清楚的是如何让 .de 域默认为德语翻译(如果以domain.com/de 或domain.com/cn 访问,则会加载)。
有谁知道如何使用 .htaccess (某种重定向)来做到这一点?或者可能是 PHP?也许根据域(PHP_URL_HOST)设置某种会话变量?
现在我有 apache2 设置,以 wwww.domain.com 作为主要虚拟主机,以 .de 和 .cn 作为别名。
i'm using Joomla with the JoomFish translation component. This website has german and chinese translations. What i'm trying to figure out is how to get the .de domain to default to the german language translation ( which would load if visited as domain.com/de or domain.com/cn ).
Does anyone know a way to do this with maybe .htaccess ( some kind of redirect )? Or possibly PHP? Maybe set some kind of session variable based on the domain (PHP_URL_HOST) ?
Right now i have apache2 setup with the wwww.domain.com as the main virtual host, and the .de and .cn as aliases.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
欢迎来到SO!
如果您的 Apache 启用了
mod_setenvif
,请将其添加到您的.htaccess
文件中:然后,在您的 PHP 脚本中您可以查询
SITE_LANGUAGE
:Welcome to SO!
Provided, your Apache has
mod_setenvif
enabled, add this to your.htaccess
file:Then, in your PHP script you can query
SITE_LANGUAGE
:谢谢你!添加 htaccess 代码后,我所要做的就是在大约 145 处编辑
/plugins/system/jfrouter.php
:Thank you! After adding the htaccess code, all I had to do is edit
/plugins/system/jfrouter.php
at about around 145:如果您在 php 中有一个基于 get 请求的选择案例怎么办?
诸如
domain.com/?lang=de
之类的内容与您的代码结合使用。
....
将是您加载翻译器或语言资源的位置。What if you had a select case in php based on a get request?
Something like
domain.com/?lang=de
in conjunction within your code.
....
would be where you load your translator or language resource.