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?

2
  • SP 2010 or 2013? Commented Apr 8, 2014 at 9:20
  • SharePoint 2013 Commented Apr 8, 2014 at 9:28

1 Answer 1

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")
2
  • Thank you! It works also SP 2013. What if I want to use external js-file? Commented Apr 8, 2014 at 9:32
  • If you want to use an external js file you need to make it SP.SOD compatible, more here: ilovesharepoint.com/2010/08/… Commented Apr 8, 2014 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.