多种语言的多个首页

发布于 2024-10-19 19:22:14 字数 1459 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

人生百味 2024-10-26 19:22:14

这个答案可能会迟到,但在花了很多时间尝试自己解决这个问题之后,我得到了以下解决方案。

对于 Drupal 7:

1- 确保您已打开模块变量和变量翻译。
2-转到管理/配置/区域/i18n/变量
3- 选择“站点信息”列表选项卡并选中“默认首页”,保存设置。
4-转到admin/config/system/site-information,您会注意到那里有一段文本,说明您的一些设置是多语言变量,以及您正在运行的语言的链接列表,允许您设置设置对于每种语言。

现在,这就是真正的问题出现的地方......单击这些链接并更改设置不会执行任何操作。所有语言的左侧设置仍然相同。解决这个问题的方法是什么?

检查您当前所在的 URL,整个内容,例如: http://www.example.com/en/admin/config/system/site-information/

注意 /admin 之前的语言前缀吗?要更改要使用的其他语言的设置,请切换 URL 中的前缀,然后进行更改。现在,就像变魔术一样,多个首页根据语言进行了适当的更改。

这肯定是 Drupal 中的一个错误,我应该抽出时间开一张票。但现在,如果其他人遇到这个问题,我希望它也能解决您的问题。

Might be late to the party with this answer, but after many hours spent trying to solve this myself, I've the following solution.

For Drupal 7:

1- Make sure you have the modules Variable and Variable Translations switched on.
2- Goto admin/config/regional/i18n/variable
3- Select the 'Site information' list tab and check 'Default front page', save settings.
4- Goto admin/config/system/site-information, you'll notice a block of text there saying something about some of your settings being multilingual variables and a list of links for the languages you are running which allow you to set the settings for each language.

Now, this is where the real GOTCHA comes up... clicking those links and changing the settings does nothing. Your left with the same settings still for all languages. The way around this?

Check the URL you are currently on, the entire thing, so something like: http://www.example.com/en/admin/config/system/site-information/

Notice the language prefix there before /admin?? To change the settings for the other languages you want to use, switch the prefix in the URL and then make your changes. And now, as if by magic, multiple front pages, properly changing based on language.

This must be a bug in Drupal, I should get around to opening a ticket. But for now, if someone else comes across this, I hope it solves your problem too.

半衬遮猫 2024-10-26 19:22:14

我一直在寻找同样的东西。我想推荐 Drupal 7 - 多语言前台页面节点,它是完整的并且非常适合 Drupal 7 项目。

I've been searching for the same. I 'd like to recommend Drupal 7 - multi-lingual front page node which is complete and works perfectly for Drupal 7 projects.

夜巴黎 2024-10-26 19:22:14

在继续为此抓狂后,我发现此功能与匿名页面缓存不兼容!

转到 /admin/config/development/performance 并关闭匿名用户的页面缓存。

After continuing to rip my hair out over this, I found out that this feature is incompatible with anonymous page caching!

Go to /admin/config/development/performance and turn off page caching for anonymous users.

蝶舞 2024-10-26 19:22:14

也许有更好的方法,但最后他就是我这样做的。

我在 template.php 中添加了以下代码:

/**
 * Implements hook_preprocess_page().
 */
function aelius_preprocess_page(&$vars) {
    if ($vars['is_front']) {
        $langcode = $GLOBALS['language']->language;

        if ($langcode == "en") {
            drupal_goto('home');
        } elseif ($langcode == "fr") {
            drupal_goto('accueil');
        }
    }
}

May be there is a better way but finally he is how I did.

I have added in template.php the following code:

/**
 * Implements hook_preprocess_page().
 */
function aelius_preprocess_page(&$vars) {
    if ($vars['is_front']) {
        $langcode = $GLOBALS['language']->language;

        if ($langcode == "en") {
            drupal_goto('home');
        } elseif ($langcode == "fr") {
            drupal_goto('accueil');
        }
    }
}
风蛊 2024-10-26 19:22:14

我还没有使用过Drupal 7 i18n,但是在Drupal 6中你可以在settings.php中的$conf['i18n_variables']中添加一个site_frontpage变量,然后依次切换到每种语言并在站点信息页面上设置frontpage 。

或者,您可以在主题 front-page.tpl.php 中指定一个条件 像这样

I haven't worked with Drupal 7 i18n yet, but in Drupal 6 you would add a site_frontpage variable to $conf['i18n_variables'] in settings.php and then switch to each language in turn and set the frontpage on the site information page.

Alternatively, you can specify a condition in your theme front-page.tpl.php like so

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文