Site column definitions displaying resource keys instead of values
-
03-10-2020 - |
Domanda
I wrote a Boris.SP.Abl.SiteColumns.sr-Latin-RS.resx
resource file for a SharePoint 2013 farm solution project. I followed the tips from here to ensure that the resource is deployed to both %15hive%/Resources and App_GlobalResources folders - and it does.
The resource file contains the Name
and DisplayName
values of site columns that are part of the solution project. However, after deployment, the site columns are displaying paths to the resource keys instead of their values.
Here is the XML of the first column in the image, to demonstrate the code:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field
ID="{c91e09c4-7e6f-48f0-9192-7fc65fc3f1c7}"
Name="$Resources:Boris.SP.Abl.SiteColumns,ActiveName"
DisplayName="$Resources:Boris.SP.Abl.SiteColumns,ActiveDisplayName"
Type="Boolean"
Required="TRUE"
Group="$Resources:Boris.SP.Abl.SiteColumns,Group">
</Field>
</Elements>
And here is the resource file with highlighted key/value pairs used in the XML above:
What am I doing wrong?
Soluzione
The issue was actually related to the culture sr-Latin-RS
unknown to .Net, even though that is in fact how it is defined by ISO. So, for all those working with this culture (Serbian language, latin writing system, in country of Serbia), the .Net notation is sr-Latn-CS
(notice the abbreviated "Latn" and country code change). This site helps for these situations.
Since I did not have the culture invariant version of the resource, the system couldn't resolve the paths to resource keys and treated them as plain strings, hence the weird screenshot in the question above.
By the way, having a fallback resource file Boris.SP.Abl.SiteColumns.sr-CS.resx
, or just Boris.SP.Abl.SiteColumns.sr.resx
doesn't work at all; instead, it immediately falls back to Boris.SP.Abl.SiteColumns.resx
. Not what one would expect...
Altri suggerimenti
While creating resource files for each language you should follow proper naming convention in order to let sharepoint recognise the resource file and keys.
So for example french resource file name Boris.fr-FR.resx and english resource file name would be Boris.resx.
After creating theses two files , deploy them into the 14/Resources or 15/Resources folder.
Then you could use
<Field ID="{79831820-B700-4786-AD10-69F54BED193B}" ShowInDisplayForm="TRUE"
ShowInNewForm="TRUE" ShowInEditForm="TRUE" Type="Text" Name="Mission"
DisplayName="$Resources:Boris,Mission;"
StaticName="Mission" Hidden="FALSE" Required="FALSE" Sealed="FALSE" />
See here for more information.