我是使用SharePoint 2013的网络设计师。我为公司创建了自定义模板,现在我想进一步使用变体功能。该网站应以德语和英文提供。

在主页的页脚上,我放置了一些类似的链接:

<a href="/Authenticate.aspx">Login</a>
<a href="/imprint">Imprint</a>
<a href="/disclaimer">Disclaimer</a>
.

,我希望它们将动态重建到我的变体网站,如德语语言:

<a href="/de/...">Login</a>
<a href="/de/...">Imprint</a>
<a href="/de/...">Disclaimer</a>
.

或此英文:

<a href="/en/...">Login</a>
<a href="/en/...">Imprint</a>
<a href="/en/...">Disclaimer</a>
.

是否有一个可变的变量,我可以放在我的主页上的链接前面?或获取当前语言的方法?

我在想这样的事情:

<a href="{Locale}/login">...</a>
<a href="$language/imprint...">...</a>
<a href="getLanguage()/disclaimer">...</a>
.

我不是ASP.NET编码器,所以我真的不知道如何了解语言。如果有人可以帮助我,我会很欣赏。

有帮助吗?

解决方案 2

I solved the problem with another method: I used SharePoints own Javascript variable - _spPageContextInfo - see: _spPageContextInfo is your new best friend !

With "currentCultureName" I could use the language name as a variable to compare to the target language and to expand my PageLayout with custom links, compliant to my variations settings.

The Code could look like this:

    $(document).ready(function() {

        $language = _spPageContextInfo.currentCultureName;

        // If it's german, I'll get german links
        if ($language == "de-DE") {
            $('.footer').html('<a href="/de/kontakt/">Kontakt</a>');
        } else {
        // And if not, it will target to the english page
            $('.footer').html('<a href="/en/contact">Contact</a>');
        }

    });

其他提示

You could use the SPWeb.Locale property of the current context (as in SPContext.Current.Web.Locale) to glean this information.

If you look at the Remarks section of the CultureInfo Class description on MSDN it will explain this.

A simple example would be:

<a href="/<%= SPContext.Current.Web.Locale.TwoLetterISOLanguageName %>/Login.aspx">...</a>
许可以下: CC-BY-SA归因
scroll top