Question

When defining a custom action via the CAML schema definition, the UrlAction parameter specifies the "site or site collection relative URL of the page, for example, ~site/_layouts/sampleurl.aspx or ~sitecollection/_layouts/sampleurl.aspx." (taken from MSDN).

The UrlAction also supports JavaScript and localizable resources usage. For example:

<UrlAction Url="$Resources:osrvcore,List_Pages_UrlName;/SomePage.aspx" />

The above references the "SomePage.aspx" in the Pages library (this example was taken from the linked MSDN page, based on a reader suggestion). The library url is localized and changes based on the language the web site was created. This would work in most situations... but seems to fall apart when the MUI support comes into play.

Let me explain: suppose that we have only two language LangA (original server language) and LangB (language pack installed later).

  • We first create a new site collection with language A and a sub-site with language A
  • We activate the MUI support on the web site/site collection
  • We define a custom action for the sub-site (created with language A) that uses the aforementioned UrlAction.
  • We switch to LangB in the MUI settings.

Now the url action will point to the path of the Pages folder localized in the LangB language. No need to say that this will break the link, I suppose...

Does anyone know if there is a supported way to handle this behavior in a caml only defined custom action? I suppose we can resort to a JavaScript workaround (or even better, define the custom action programmatically in a feature), but I was wondering if I am missing something obvious here.


EDIT - To further elaborate: SharePoint provides "two" conceptual ways to localize a resource (please forgive the simplification here):

  • Based on the website language: each SPWeb instance provides indication of the language the site was created with.
  • Based on the Thread CurrentUi culture: based on the MUI inner working, you can use the ui culture of the current thread -Thread.CurrentThread.CurrentUICulture- to support localization (this is again a simplification, but should serve to illustrate the problem).

When we write "Url="$Resources:osrvcore,List_Pages_UrlName;/SomePage.aspx"" the resource gets localized in the second way (MUI-aware). I'm wondering if there is a way to force localization based on the original web site locale.

Was it helpful?

Solution 2

It would seem that (at last until SP2010) this behaviour isn't supported, so resources used in defining custom actions by CAML will always be resolved in MUI aware mode.

As said in the question, this will break the action under certain conditions - for example if the action points to the Pages library. As now it seems that there isn't any CAML only solution to this bug, so I have resorted to defining the action in codebehind.

(I am leaving this answer as a reference for anyone searching the same topic. If anyone finds out something different, feel free to leave his answer and I will update the post as needed)

OTHER TIPS

If I understand your example correctly I think it's impossible to create a library with MUI-enabled name. The url fragment you're trying to localize is a folder in the file system in SP content database. It can be viewed in Windows Explorer via Web-DAV, for example. How do you think this localization can be handled on the file system level?

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top