문제

저는 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 ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top