Hot answers tagged resource-files
6
Yes, take a look into the file
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Resources\core.resx
The format is :
$Resources:name_of_resource_file, key_of_ressource
A warning thought, this will concerns the resources you will find in all xml files, or in code.
In aspx markup, the resources will be read from
...
6
You can add fields programmatically using list.Fields.AddFieldAsXml, providing CAML field definition with resource tokens in it.
Or you can wrap SetValueForUICulture in a nice helper method, and gain a capability to use it for any SPUserResource object. We're using this approach at work, and I would not say, that it is unclear or smth like this :) It's ok, ...
3
RegisterSod doesn't fetch the script file. You must load it. Use LoadSodByKey, or use the plain tag to load it synchronously. I wrote a blog post about how to use javascript localizaton in SharePoint and scriptresx.ashx . Waldek Mastykarz shows how to use it with RegisterSod. But you have to know, that the script won't be downloaded before you explicitly ...
3
I don't think you can reference it statically like that. Try this instead:
<h2><asp:Literal runat="server" ID="Literal1" Text="<%$Resources:MyProject,Test_String_Heading%>"></asp:Literal></h2>
EDIT: it's $Resources versus &Resources. Thanks for picking that up Bojan!
UPDATE: As noted below the $Resources method of ...
3
For shared resource files in SharePoint (i.e. RESX files that must be shared amongst Features/Projects/Solutions), the best thing to do is to deploy them to the SharePoint Root's "Resources" folder (14/Resources). Then you'd reference them in one of two ways.
In the RESX reference, you can specify the file name in the RESX reference like so (leaving off ...
2
You mean like this?
using (SPSite site = new SPSite("http://localhost"))
{
using (SPWeb web = site.RootWeb)
{
if (web.IsMultilingual)
{
IEnumerable<CultureInfo> cultures = web.SupportedUICultures;
foreach (CultureInfo culture in cultures)
...
2
The default language for a whole SharePoint system is based on the installation language of original SharePoint installation media and cannot be changed (without a re-install). With additional language packs, site collections can be created in a selection of languages, but once again, once the site collection has been created, the default language cannot be ...
2
SharePoint fallback is not like the ASP.NET fallback to the invariant culture; is first use the thread CurrentUICulture, then fallback to the SPWeb.Language: http://blogs.msdn.com/b/sharepointdev/archive/2011/07/01/localizing-the-sharepoint-user-interface-by-using-resource-files-sanjay-arora.aspx
2
I have the same issue in our SharePoint projects, but gave up on it because it appeared that SharePoint wasn't applying the resource fallback mechanism like I expected it to. Then I saw this post and decided to research this a little.
I came across this article http://msdn.microsoft.com/en-us/library/ee696750.aspx and it says that a Default resource is:
...
2
If you are asking how to add them to your project, you can map the Layouts folder by right clicking on your project and selecting Add, SharePoint "Layouts" Mapped Folder. That should create a folder with the same name as your project. Anything that you add will be available globally in the /_layouts// folder.
It is also possible to map to the SharePoint ...
2
You can't have resources files in webtemp*.xml files... Those are already localized with the folder that contains them.
For example, check the file webtempsps.xml in the path C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\TEMPLATE\1033\XML. You will see that every string literals are in fact real string, and not in the format ...
1
Localization of feature.xml differs from localizing something else. As by Microsoft's reference, you have to create a special Feature resource file (which will be stored along with the feature) in order to do that:
How to: Localize a feature (MSDN)
Based on my experience, if you deploy your resources into "Resources" mapped folder (in 14 hive), they will ...
1
According to MSDN, the SPResource methods retrieve the localized strings from the microsoft.sharepoint.intl.dll assembly, not .resx files.
[I don't have access to SharePoint assemblies at the moment to decompile them and confirm this information - if you do it, post a comment or edit this answer and write what you found.]
1
are you using embedded resources and accessing them in Sandbox solution likely?
See more details: http://blog.sharepointbits.com/2011/03/localization-in-sharepoint-2010-sandbox.html
1
Make sure your format to pick the name from the Resource file is:
Name="$Resources:MyResources,TagsListInstanceTitle"
MyResources – name of the resources file (as described below)
TagsListInstanceTitle – the resource entry
And the name of Resources file (for the entry above) for English should be:
MyResources.en-US.resx
And deployed to:
...
1
SpContext.CurrentWeb.Language always returns languages that is used for site creation, if you would like to change languages on your site dynamically you should use `Thread.CurrentCulture.LCID'.
If you would like to get this values in .aspx file, you should create module that deploys resources files to the GlobalResources folder. See this post how to do it.
...
1
This is exactly what the SharePoint wsp package format is for. A quick Google found these 2 links.
http://blog.mastykarz.nl/provisioning-appglobalresources-sharepoint-2010/
http://social.technet.microsoft.com/Forums/en-GB/sharepoint2010programming/thread/bdd711d9-cc57-495e-810a-d4fcc70d68ec-
More on Google.
Only top voted, non community-wiki answers of a minimum length are eligible