CHunky Universe of Vigourous Astonishing SHarepoint :)

JavaScript Localization in SharePoint

Yesterday Waldek Mastykarz published a cool post: Globalizing JavaScript in SharePoint 2013. This is a very cool technique to localize your client code in javascript and reuse your resx files in Server Side and Client Side. This is actually not new for SharePoint 2013 despite it has become more needed with the huge client focus in the new SharePoint. I have used this in SharePoint 2010 for a long time. In my blog post: ScriptResx.ashx in SharePoint I told about that technique. What I didn’t know that you can define your javascript namespace directly in the resx file. Waldek wrote in his comment that SP.Publishing.Resources.en-US.resx automatically are SP.Publishing.Resources in javascript. That was not the case for my own localization files. A simple look at SP.Publishing.Resources.en-US.resx helped:


    Whether this .resx could be read by scriptResx.ashx handler. Only a file
    marked with scriptResx:true could be returned to client.
  <resheader name="scriptResx">
  <!-- the full name of the JavaScript class.  -->
  <resheader name="classFullName">

This results in:


So what we have to do for our custom resx file is to add classFullName resheader:

  <resheader name="classFullName">

12 responses to “JavaScript Localization in SharePoint

  1. Pingback: ScriptResx.ashx in SharePoint « Share… What?

  2. Johan Frisell 2013-02-07 at 11:43

    Great post – as always 🙂

  3. Daniel 2013-02-18 at 13:48

    Hi! Great post! I’m try to use my own localization file, i register it using
    SP.SOD.registerSod(“test.sp.publishing.resources.resx”, “/_layouts/ScriptResx.ashx?name=test.sp.publishing.resources&culture=en”);
    I´m using the namespace TEST.SP.Publishing, but i can’t access it from javascript. Something wrong?


    • Anatoly Mironov 2013-02-18 at 13:52

      Hi Daniel! Try to get it to work without SP.SOD first. Just paste your url in Chrome and see what you get. I think, culture has to be defined like “en-US”, not just (“en”).

  4. Daniel 2013-02-18 at 14:05

    Not work!
    I’ve used now RegisterSod(“test.sp.publishing.resources.resx”, “/_layouts/ScriptResx.ashx?name=test.sp.publishing.resources&culture=en-US”);
    If paste url in Chrome i can see correctly:

    But just execute RegisterSod(…..);
    Try to use TEST.SP.Publishing.Resources and console return “ReferenceError: TEST is not defined”


    • Anatoly Mironov 2013-02-18 at 14:10

      Allright. So there is no problem with the script reference. It is just SP.SOD handling. The easiest way is not to use SP.SOD just reference your script like <script src=”/_layouts/ScriptResx.ashx?name=test.sp.publishing.resources&culture=en-US”></script>

      When you want to take an advantage of SP.SOD you must check the documentation for SP.SOD: RegisterSod doesn’t load your script.

      • Daniel 2013-02-18 at 15:54

        The problem is that i can’t use the …to reference because i’m trying to load directly from javascript


  5. thomasdah 2013-02-25 at 14:54

    Here some additional info about localization with angular:

    • Anatoly Mironov 2013-03-19 at 10:21

      Thank you Thomas. The combination SharePoint + Angular is awesome and scriptresx localization can help localizing the new sharepoint apps.

  6. Kannan 2015-02-02 at 04:52

    Hi Anatoly, I defined a resource file with scriptResx and classFullName elements but when I run the url from browser its blank. Any Ideas how to troubleshoot this…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Daniel Chronlund Cloud Tech Blog

News, tips and thoughts for Microsoft cloud fans

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Architect, Speaker, Author

Microsoft 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Mai Omar Desouki

PFE @ Microsoft

Cameron Dwyer

Office 365, SharePoint, Azure, OnePlace Solutions & Life's Other Little Wonders


Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

DevOps, Cloud and Blockchain Consultant


SharePoint for everyone


Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint


Mostly what I know and share about...

%d bloggers like this: