1

I'm looking for changing my title using a file .resx. I thought i'll just have to change title with my resx file

for example : title : Resources:MyFile,MyTitle

but it's not working

          <CommandUIHandler Command="MyButtonCommand"
                              CommandAction=
    "javascript:
    {
      //several stuffs

                    var options = {
                        url: optionUrl,
                        title :'Title of my webPage',
                        allowMaximize: true,
                        showClose: true,
                        autoSize: true,
                    };
//several stuffs

this code works, but i can't use a .resx file, juste write the title.

Any idea ?

0

As far as I know, there is no simple supported way to achieve this directly (I think you may be able to put together some sort of workaround that uses ASP literal controls, but even if possible I would try to avoid it).

I would therefore consider another option. Since your localized text is going to be used in a JavaScript script, why don't make the resource a JavaScript file too?

First, create a .js file that will represent you resource. Inside it you probably want to just create an object with some properties representing your labels (you should probably define a JavaScript namespace too, just in case).

Then you copy that file for each language you need to support.

The final step is to make it available on the page. For this, you want to use the ScriptLink server side control

<SharePoint:ScriptLink language="javascript" name="[javascript logical path]" 
     runat="server" localizable="TRUE" />

As you can see in the above example, the ScriptLink tag supports a "localizable" attribute. Setting this flag to true enables you to use multiple versions of the same "logical" file based on the current locale.

For example:

<SharePoint:ScriptLink language="javascript" name="myResource.js" 
     runat="server" localizable="TRUE" />

will load the file at /_layouts/15/1033/myResource.js if the current locale is 1033 (English US), but would instead resolve to /_layouts/15/1031/myResource.js if the current locale is 1031 (German).

This should enable you to use the appropriate resource file for each supported language. You just need to find a way to have the resource linked on your page (I think you may as well use a delegate control registration, but the final decision really depend on your environment/requirements).

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.