Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I followed this tutorial to create a resource file named GlobalResources.resx under Resources.

Resources file in root

I am able to access the content of the resource file using:

string resourceVal = SPUtility.GetLocalizedString("$Resources:GlobalResources, ResourceKey", 
"GloablResources", language);


However, to follow company coding standards, I am required to move the resources file into a folder named <client>.<project>.<department>.<farm|sandbox>.
So I did this:

Resource file in sub-folder

But now I'm not able access the resource values!

I tried the following...

(a)

SPUtility.GetLocalizedString("$Resources:Comp.Dept.Proj.Farm/GlobalResources, ResourceKey", 
"Comp.Dept.Proj.Farm/GlobalResources", language);

(b)

SPUtility.GetLocalizedString("$Resources:Comp.Dept.Proj.Farm\\GlobalResources, ResourceKey", 
"Comp.Dept.Proj.Farm\\GlobalResources", language);

(c)

SPUtility.GetLocalizedString("$Resources:Comp.Dept.Proj.Farm.GlobalResources, ResourceKey", 
"Comp.Dept.Proj.Farm.GlobalResources", language);

...but none of them worked.

How do I access the resource file that's not in the root of the Resources folder?

share|improve this question

3 Answers 3

up vote 2 down vote accepted
SPUtility.GetLocalizedString("$Resources:YourKeyValue", "Comp.Dept.Proj.Farm\\GloablResources", 1033);

plz refer this link http://geekswithblogs.net/venkatx5/archive/2010/12/14/how-to-create-multilingual-webpart-in-sharepoint-2010.aspx

share|improve this answer

did you try this $Resources:Comp.Dept.Proj.Farm\GlobalResources or $Resources:`/Comp.Dept.Proj.Farm/GlobalResources?

also check this msdn for http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.getlocalizedstring.aspx

check this guy http://blogs.msdn.com/b/joshuag/archive/2009/03/07/using-resource-files-resx-when-developing-sharepoint-solutions.aspx

share|improve this answer

The folder becomes part of the namespace. I think you are almost there with option c), but as first parameter write the key "$Resources: ResourceName".

For example if in the resource file you have key-value pair with name = "MyFieldName" and value="MyField" then this should work:

SPUtility.GetLocalizedString("$Resources:MyFieldName", "Comp.Dept.Proj.Farm.GloablResources", language);

And don't forget to run copyappbincontent command.

share|improve this answer
    
Thanks for the asnwer, but sorry, specifying the resource filename as Comp.Dept.Proj.Farm.GlobalResources didn't work for me. Instead, Comp.Dept.Proj.Farm\\GlobalResources did. –  SNag Dec 24 '13 at 8:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.