質問

私はSharePoint 2013を使ったWebデザイナーです。私は会社のカスタムテンプレートを作成しました。Webサイトはドイツ語と英語で利用可能になるはずです。

マスターページのフッターでは、このようなハードコードされたリンクを入れました。

<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帰属
所属していません sharepoint.stackexchange
scroll top