0

I need to replace one word in my SharePoint site, depend in on that what language is used. I found this question: Get the current UI language with ECMAScript

I tried to use that code and it works only, if I add it into script editor and my page is in edit mode. If I try to add it to master page, it won't work. If I add it to external js-file, it won't work:

Firebug gives error message:

"SP.Res is undefined"

Master page code: ExecuteOrDelayUntilScriptLoaded("multilanguage.js", "sp.js")

If I try to use other solution (same link, last post), Firebug gives error message:

"ReferenceError: g_wsaLCID is not defined"

"var lcid = g_wsaLCID;"

My example code:

<script type="text/javascript">
var lcid = SP.Res.lcid;

if(lcid == "1033")
{
    alert('English'); /* Works only, if it in script editor and page is in edit mode */
}
</script>

What I'm doing wrong? How I can get it to work? Why it is working only script editor and page is edit mode?

0

You should not use the file name in ExecuteOrDelayUntilScriptLoaded. but the function you want to trigger. Try this in your masterpage (2010)

ExecuteOrDelayUntilScriptLoaded(function(){
    var lcid = SP.Res.lcid;

    if(lcid == "1033")
    {
        alert('English'); /* Works only, if it in script editor and page is in edit mode */
    }
}, "sp.js")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.