كيف يمكنني استخدام اللغة الحالية كمتغير في صفحتي الرئيسية؟

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/80074

سؤال

أنا مصمم ويب يعمل مع SharePoint 2013. لقد أنشأت قالب مخصص للشركة والآن أريد أن أذهب إلى أبعد من قدرات الاختلافات.يجب أن يكون الموقع متاح باللغة الألمانية والإنجليزية.

على تذييل الصفحة الرئيسية، قمت بوضع بعض الروابط الشديدة المشفرة مثل هذا: giveacodicetagpre.

وأريد منهم إعادة بناء موقع ديناميكيا إلى موقع الاختلافات الخاصة بي مثل هذه اللغة الألمانية: giveacodicetagpre.

أو هذا باللغة الإنجليزية: giveacodicetagpre.

هل هناك متغير يمكنني وضعه أمام الروابط في صفحتي الرئيسية؟أو طريقة للحصول على اللغة الحالية؟

كنت أفكر في شيء مثل هذا: giveacodicetagpre.

أنا لست مبرمج 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