views:

147

answers:

2

Hi,

is the concept culture (as with .NET CultureInfo) to be used solely in localizing appearance of a website (language, date- and numberformatting etc.), or can it be used for localizing website content (location-bound newsmessages, contactdetails etc..)?

I need to build a website which supports both multiple-languages as localized content. I found that for instance there is no way to specify Dutch language in the United States ('nl-US'). I would like to specify both language and location in the url of the website. Does this imply I need to go like: www.domain.com/en-US/Netherlands/ ?

I hope my problem is clear.. Thanks in advance.

+1  A: 

It can do languages as well; with resx files. Check around for a few tutorials; it's quite beautiful.

-- Edit: Tried to find some for you, best I can come up with is: http://msdn.microsoft.com/en-us/goglobal/bb688096.aspx, probably someone else can provide more specific links.

A very quick overview is that you can add various resx files (.es-ES, .es-CO [if that's the one for colombia) and then bind the entries in those files to controls (or use them just as global variables for various purposes). In this way you have a label like:

(Not exactly that, but something like that, please correct me if I'm slightly wrong) and it will get the appropriate text for whatever language the browser that the user is using has requested (you need to make a slight change in the web.config for this info to get passed in though). It should all be layed out for you in the link I've provided.

Noon Silk
Lol, thanks for the link, been there done that. Maybe some advice on how to look at the 'location' part of the culture. This only seems to cover the 'local' language, currency and formatting issues. Not 'localizing' business content......?
Ropstah
Ah, expanded while you commented :) Hope it's clear? What do you mean by 'Business Content'? You want to assume that the locale suggests the country? You can do that, but it will be a little confusing; I suggest you have different URLs for that purpose (so it's clear to search engines, and people can link each other clearly to specific portions of the side).
Noon Silk
By business content i mean content, not display/formatting (language, etc..). I want product X to be on the frontpage for the US and product Y to be on the frontpage for Japan (bit more complex obviously). I also want search engines to fetch both US and Japanese sites in ALL languages in which they are available. I only want to use 1 (one) .com domain. I think Ed understands what I'm talking about...
Ropstah
ropstah: You can make decisions based on the locale, as I said (in code, you just decide what to do), but probably I'd do it slightly differently (as I said above) and use the url-based approach (i.e. be explicit about it), because it makes life easier for everyone (as I said in my above comment).
Noon Silk
It is never safe to make assumptions based on locale, since the user is in complete control of that. If you really want to know where they're coming from, you have to detect it apart from their current language and culture settings.It's fine if you don't need accurate data to do this, but you're going to get a bunch of people in the US who are using other locales on their systems.
Ed Altorfer
Ed: It's perfectly acceptable to set the language of the site to the locale of the browser; that's WHY they have it set that way (to make websites behave differently). As I've explained to ropstah, though, it's not a good idea to make business-y decisions *soley* on this; it should be done explicitly.
Noon Silk
Not sure what you mean by explicitly, since there is no way to determine for sure what country a user is in. OP has implied that he wants to actually provide location-specific content in a specific locale. This could be something like US content in French, which you couldn't derive from the user's locale settings.
Ed Altorfer
ED: Explicitly means *you ask them*. (i.e. make it an option).
Noon Silk
From a UX perspective, I think that's bad form. You shouldn't prompt users for information if there's a reasonable default; in this case, the reasonable default would either be to accept the inherent inaccuracy of relying on locale, or to use the IP mapping, which (IMHO) is more true to what OP is trying to accomplish.
Ed Altorfer
Ed: You're welcome to think that. And I'm welcome to consider you wrong. We don't need to agree :)
Noon Silk
+2  A: 

The culture codes are internationally recognized. The reason you see them as things like fr-FR for French (France) is that French is spoken in multiple countries and varies in those other places. This allows people who are translating to focus on the nuances of a particular dialect of a language.

You can't just stuff any country code you want in there. You should track the country separately if you need it.

Edit: Based on the comments, I want to include some more information.

  • If you need to figure out what country a user is actually in regardless of his or her locale, consider using IP to ISO-3166 country code mapping.

  • If you want to allow users to change their language regardless of their country but you still need to track where they're coming from, do the following.

    1. Detect their country using the ISO-3166 country mapping above.
    2. Default to their current locale (i.e., if they have their computer set to en-US, use English).
    3. Display a dropdown somewhere with all your supported locales and their languages and let them swap whenever they want.

I think this covers all your questions/scenarios.

Ed Altorfer
Clear answer, how is this called? When searching for localization, globalization or culture I end up setting locale stuff... I also need country specific content but in a manageable way...
Ropstah
I'm not sure -exactly- what you mean by this, but I'm assuming your question is how to determine which country the computer is in. You might consider IP -> ISO-3166 country code mapping. Use the client's IP address if possible. http://www.codeproject.com/KB/cs/iptocountry.aspx
Ed Altorfer
The client should be able to choose location (US website, Japanese website..) but also to be able to choose a language (Dutch, German..). So it might be that a user will come to the Japanese website, with Dutch language selected. This translation probably won't exist, but that's not the point. What if a client wants normal spanish as language and Mexico as location, does this mean: xxx.com/es-ES/Mexico/ or the other way around: xxx.com/es-MX/Spain for Mexican spanish in Spain?
Ropstah
I'd suggest choosing their country for them using the IP to country mapping I linked you to above. If you want them to be able to choose their language, then just enumerate all the locales you support in a listbox somewhere and let them switch at will. Default it to whatever locale is used in their home country—if you're in France, use fr-FR.
Ed Altorfer
I don't recommend using IP-to-country as the only method; better to make it explicit.
Noon Silk
There is no 100%-sure way of obtaining the user's country without using some method like that. It is likely to be more accurate than using the user's locale, which is purely determined by the client. The only issues you'll have with the IP translation will be if the user is visiting your site over an international VPN or something.
Ed Altorfer
Ed: Yes, but the more common scenario is that a user is trying to view an international site from another country (often something you want to do, if buying products or booking hotels, etc). So it depends on what type of site. Typically, though, almost all large sites *don't* force a country on you, you can choose it.
Noon Silk
I never suggested that the user be forced to do anything. I suggested that OP detect the country and store it for whatever he wants to do, and then DEFAULT to the user's locale (e.g., the information set by the client) and allow the user to switch at will. I suggest this because OP states that he wants to be able to determine the user's country in ADDITION to their locale.
Ed Altorfer