Question

Je suis un concepteur Web travaillant avec SharePoint 2013. J'ai créé un modèle personnalisé pour une entreprise et je veux maintenant aller plus loin avec les fonctionnalités de variation.Le site Web doit être disponible en allemand et en anglais.

sur le pied de page de la page maître, j'ai placé des liens codés durs comme celui-ci:

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

Et je veux qu'ils se reconstruisent de manière dynamique à mon site de variations comme celui-ci pour la langue allemande:

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

ou ceci pour l'anglais:

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

Y a-t-il une variable que je pouvais placer devant les liens de ma page maître?Ou une méthode pour obtenir la langue actuelle?

Je pensais à quelque chose comme ça:

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

Je ne suis pas un codeur ASP.NET, donc je ne sais pas vraiment comment découvrez la langue.J'apprécierais que quelqu'un puisse m'aider.

Était-ce utile?

La solution 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>');
        }

    });

Autres conseils

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top