How To Store/access Localized UI Strings In Sitecore
Apr 4, 2011
I'm adding support for multiple language to my site. I've found many places in my renderers that have hard-coded strings I'll need to address.
I seem to have a couple different options of fixing this... one would be to use the standard .NET approach and store strings in a resource file. I'm not liking this because my Sitecore translators can't get to that... and also because I don't think Sitecore sets the Culture by default? Which I believe is how ASP.NET knows which language to use from the resource file.
Another option would be to add fields for all these strings in my Sitecore templates so they are visible to translators in Content Editor. But this seems like a huge hassle... there are many, many places where I would have to update my templates solely to store UI element strings.
I got an assignment to localize the website and to store all string values into the XML file. The reason for that is to let the sys. admin to change the localized values himself by editing XML file. Should I read the content of XML file and store in the memory on application startup? I guess there's a best practice for this kind of scenario.
In IIS 7 you can create database connection strings. I suppose this must be encrypted and best protected by IIS. This is nice, but how do I access it programmatically?
I want a piece of code for asp.net 3.5 using visual basic. and i am using MS access database.
I have two three text boxes and 2 image upload controls and a submit button.
I want a piece of code in which a user can upload images and store it in our database . i want an asp.net visual basic working code. also i need query behind the submit button.
I am using ajax html editor to write a text. I can view it without having problem but I am incapeble of storing it in a Ms Access database. which type do I need to use for this? I tried memo and OleObject type and both didn't work. I used the blow code for that.
im trying to store a date in an Access database i set up the column in the db to be type Date/Time and have the following code to attempt to insert into itDim objTest As New OleDb.OleDbCommand("INSTERT INTO orderForm (OrderDate) VALUES (@OrderDate)", objConn) objTest.Parameters.Add(" OrderDate", DateTime.Now) Dim objTestExec As OleDb.OleDbDataReader = objTest.ExecuteReader()
however it yields the following error when i execute invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.ive also had a variety of other errors with my efforts so im not really sure what the deal is here
integrate AspDotNetStorefront and Sitecore? I've been trying for the past couple of days to come up with a way to get the two systems to play nicely together, but it doesn't seem feasible from what I can tell. A couple issues I've run across so far:
Authentication between the two (AspDotNetStorefront has its own implementation, Sitecore just uses/extends .NET Membership)The main DLL for AspDotNetStorefront is what pops up in the stack trace when I get yellow-screened, but that DLL is obfuscated so I can't figure out what the problem is.
we need to keep our existing AspDotNetStorefront application as an e-commerce backend and use Sitecore to do everything else. AspDotNetStorefront has a CMS as part of it, but it's really not an acceptable solution for anything but really basic content pages.
EDIT:
I've decided to break this whole thing down into the different problems that I am facing at the moment and solve each one as efficiently as I know how. I'll detail the ones I have here and then update when I run into new ones.
Problem 1: Authentication between the two systems.
This one isn't too bad actually if you're knowledgeable about forms authentication tickets, which I wasn't at the time but am learning quickly enough. As long as the two systems share the same encryption info, it's easy enough to pass information back and forth between them using cookies as stated below in the accepted answer. The other kicker is that I needed to set the CustomerGUID in the AspDotNetStorefront Customer table to be the user ID from the Sitecore user tables (standard ASP.NET membership). So far this approach seems to work pretty well (I'm still in the proof of concept stage at the moment.
Problem 2: Getting at the product data
This one was a little more troublesome. The aforementioned web service has a few issues I've had difficulty working around. However, since the databases are going to be on the same server, I simply decided that since all I really need is the price and ID I would go ahead and set the ProductGUID column of each product in the Storefront database to match the Sitecore item ID of the corresponding item in the Sitecore database. This way I just need a quick query to grab the ProductID and price information which is only used in a few places. Everything else is going to be housed in Sitecore.
If anyone has anything to add feel free, as far as I can tell from Google, no one has actually done this before, so I'm having a lot of trouble finding resources on this particular topic.
UPDATE:
The integration is in fact possible and our site has been up for a week and a half now with very few integration related problems. This isn't something I recommend doing really on a personal level, but it is in fact possible to pull off.
The Faking User Roles document in SDN appears to give exactly what I need. I have a few "roles" that I have access to through stored procedure calls I don't control, read-only, via a CRM I don't have direct access to.
Unfortunately, I can't find the method AddRole, or even the class UserItem, by its present name. Does this functionality exist in Sitecore 6.2? If so, where is it?
I'm trying to change the layout of the home item, but the whole layout section seems like it doesn't do anything. How do I change the layout of something?
I have a section on my website where I plan to add a lot of text-based content, and rather than display this all at once it would be nice if I could add paging on just these pages. If possible, I would like to put all of my content within one content item and have the paging work automatically, building a URL along the lines of http://example.org/articles/title?page=2 or similar.
I've stumbled across an article that mentions paging with Sitecore items and this seems rather close to what I require, although mine requires pagination on a single content item, rather than multiple items.
Is it possible to do this with a Sitecore content item?
I'm getting some strange behaviour with viewstate being lost on postback for a .net application using Sitecore. I'm assuming it might be some config variable somewhere but I'm new to Sitecore and don't really know where to start looking.
UPDATE: Sitecore has now gotten back to us with an answer. We had recently added the dtSearch module, and AutomaticDataBind was set to true in the dtSearch.config which overrides the setting in the web config. We've now removed it and it works fine again.
I've made a mini test if that might help. It's two usercontrols on one page, both with a repeater. When updating the viewstate gets lost so even if I'm binding the updated repeater again the data for the other one will be lost.
what might be going on? Let me know if I need to provide any more information. The most annoying thing is that it was working last week but I have no idea what has changed!
I might be overlooking something obvious here, but is it possible to return a Sitecore user with the username in the capitalisation they used when registering?
At the moment the username will be displayed as whatever the user typed when they logged in, but I'd like to be able to get the original string.
I'm using User user = User.FromName(domainUser, false);
UPDATE: This is what I ended up with after Yan's excellent answer:
// get the MembershipUser object normally by name var initialUser = Membership.GetUser(domainUser, false); if (initialUser != null) { // get the same MembershipUser by Id - in this case it retuns username in correct case initialUser = Membership.GetUser(initialUser.ProviderUserKey, false); } // get the Sitecore user from the username in correct case Sitecore.Security.Accounts.User user = Sitecore.Security.Accounts.User.FromName(initialUser.UserName, false);
I'm trying to debug sitecore 6 asp.net code using visual studio 2008 (Windows server 2003 OS), concretely i am trying to get breakpoints to work. I tried setting the breakpoint and then on VS, debug-> attach to process.. -> IIS web server process, but nothing happens when i browse to a certain aspx where a breakpoint is located at the beginning of the Sitecore.Web.UI.WebControl.DoRender method
I tried setting on the website properties home directory->configuration->debugging and check both client-side and server-side debugging but nothing changes. Tried stopping the website, recycling the appPool and restarting, reataching the debugger and nothing happens
my web application uses a menu for the user navigation, and I need to store the menu in the database. among other properties, each menu item has a text title. But I do not want to store title strings in the database. Instead I want to use resource files to plug in the right language. I am looking for an advice on how to link the database table and the resources together. I mean, what would a store instead of the title in the database? the corresponding resource id? But this seems wrong.
I am writing extensions to a web app that doesn't need to be localized. As the company grows I believe there is a possibility that there may be some effort in the future to do this localization.Mindful of that I would like to mark all of the place that I am using country-specific date formats in an attribute on the method, for example:
For Each exception As String In exceptionDates Dim DateBits() As String = exception.Split("/") dates.Add(New Date(Integer.Parse(DateBits(2)) _
Is there a way to use user's culture to localize the Range Validator for date? I am looking for a good way to validate date and avoiding to provide a fix format (e.g.: do a dd/mm/yyyy using Regular Expression Validator)
I have an ASP.NET application that accesses private key in a certificate in the certificates store. On Windows Server 2003 I was able to use winhttpcertcfg.exe to give private key access to the NETWORK SERVICE account. How do I give permissions to access a Private Key in a certificate in the certificate store (Local ComputerPersonal) on a Windows Server 2008 R2 in an IIS 7.5 website? I've tried giving Full Trust access to "Everyone", "IIS AppPoolDefaultAppPool", "IIS_IUSRS", and everyother security account I could find using the Certificates MMC (Server 2008 R2). However the below code demonstrates that the code does not have access to the Private Key of a certificate that was imported with the private key. The code instead throws and error everytime the private key property is accessed.
i'm currently having a nightmarish moment with Sitecore. Basically my issues are two-fold:
1) the first time i added a standard value item to a template, and added a layout setup to it, i was thrilled, since all my items from that template were showing the layout, however now, certain items are now showing no layout at all. I tried doing presentation->layout, reset several times, but to no avail.
2) i added a new sublayout to the standard value layout to another placeholder, did publish on the template (republish everything, publish subitems), then publish on the standard values item again, just in case (should not be needed), i click on all items from the template, and they show the updated layout with the new sublayout (should be good, right?) however, i browse, both live and with preview to the pages and i am still seeing the old layout without my new sublayout.
I have a string, that could look like "123,34", "123123,09", "1234", "123.34", "123123.09"
(Stringrepresentation of 10,2 decimal that will be stored into a MySql DB)
Due to the culture of the ASP.net thread may differ, because my application supports localization, I need to find a safe way to convert the most likely user input into a decimal.
How is that possible?
I tried various Decimal.Parse attemps, that all failed so far.
Solution:
My final solution was a mixed one. I used string replace to ensure my date is formatted into the specified CultureInfo I used for parsing
How to use localized messages in javascript file in asp.net.
i have a javascript file(global-Scripts.js) which contains all my scripts.i use another file (messages.js) which has all the static error messages( ex: are you sure you want to delete ?) so that this can be localized.Is it possible localize this main script file without having another file(messages.js),so that i can remove one script reference ...
What is the recommended or usual way an ASP.net web application(in C# language) can store/access values that are needed accross the various pages in a website. For example a basic company website might need the company's name and other related information available to multiple pages. Where do I declare these variables/values and how do I access them. Coming from c++ application programming I would usually store such data in a Singleton class object.
I need to keep access settings to different web pages inside of my asp.net application. These setting are logins and passwords for those pages. Is it safe enough to keep them in web.config in section?
I have some global settings in my application that is going to be handled by the administrator and I store them in the database.
Settings like: board on/off, max items/page on different UserControls, language, hide/show modules.
What technique should I follow to read the values in the database and display the page or the application according to it .. Of course I could do it the easy way and fetch the required settings for each page in the Page_Load event handler but I think that will be a lot of database connection!