Tuesday, June 28, 2011

Changing the default language of existing Site collection or Web

While working on one Norwegion project I thought is there a way by which we could change the language of already created site collection so that we will not need to use Google translator to translate again and again.

After googling for few mins i found this article which says there is only one way to do so and its to run the sql update query


For changing the language of all sites in the content database to Dutch the query would be:
UPDATE dbo.Webs SET Language = 1043

Changing the language of one site collection can be done with:
UPDATE dbo.Webs SET Language = 1043 WHERE SiteId = [[SiteCollectionId]]

And for changing the language of a single web or subsite you can use:
UPDATE dbo.Webs SET Language = 1043 WHERE Id = [[WebId]]

Although it not a correct way to do so but while development if you want to see buttons text in english instead of other language which you cannot read then this is good alternative.

Just goto Central admin and find the content db of desired SC, get the id using manager and run the query.




Thursday, June 9, 2011

Generic method to get the SPListItem data from field internal lname or display name

Into one of the method of my code i had to display the list item data, but only those fields/columns that are set by Editor.

Now till that point i only knew that Editor will put column names in property bag as comma delimited but whether he will set internal name or display name of fields, no idea.

So I had to get the fields data by using some method which takes both Internal Name and Display name as parameter.

And here is the solution:

foreach (string field in fields)
details += Server.HtmlDecode(delimiter) +
Convert.ToString(item[item.Fields.GetField(field.Trim()).Id]);

Updated one entry of my custom resource file, but it does not get reflected in my web part

While working on one fix I faced on strange issue when I updated one entry of my custom resource file, but it did not get reflected in my web part.

I tried following but no effect:

* Deployed my solution
* Restarted IIS Manager
* Even gone to '14\Resources\MyFile.resx' and updated manually
* Deleted file from '14\Resources\MyFile.resx' and then deployed again
* Added new resource entry and updated my code

but with my last try I came to know that it is not picking resource data from '14\Resources folder' and instantly another location came into my mind and its

'C:\inetpub\wwwroot\wss\VirtualDirectories\9001\App_GlobalResources'
When i opened my resource file from this path.. it was old file....

So after updating here my issue got fixed, I cannot say its solution of all this kind of issues but it worked for me :)