I am building a multilingual web app. The client requires the site for HK to be displayed in English. Unfortunately, "en-HK" is not a valid culture in asp.net, so I tried to get around it using "zh-hk". However, this caused the date time strings (with format of dd-MMM-yyyy) to be displayed in Chinese.
Is there any way to display the language in english but localise it to Hk?
CurrentUICulture controls selection of localized resources: set it to an English culture (e.g. "en" or "en-GB").
CurrentCulture controls number and date formats etc., including day and month names. Either set it to "en-GB", or set it to a custom culture based on "en-GB", but with any modifications you want (e.g. your post suggests you want "-" as date separator: dd-MMM-yyyy).
Neither of these affects time zone etc, so I don't really see why it would be a problem simply to use "en-GB".
I don't know much about Hong Kong but given its recent history, the English language conventions used there are probably based on UK English rather than US English. The short date format used in Hong Kong (documented on Wikipedia here) certainly appears to support this assertion: it's day/month/year (British style, unlike the US style where it's month/day/year).
You could always create a custom culture (supported by Windows 7 onwards) for en-HK. This is done by using the CultureAndRegionInfoBuilder class and will allow you to create your en-HK CultureInfo, based on the en-GB culture if my comment above is correct. This would allow you to customize some of the elements of the CultureInfo if you wish to (and more importantly, if you know what is different in Hong Kong). By basing your custom culture on en-GB, your date formats will show month names in English. But creating a custom culture is probably overkill.
More simply, you could use the en-GB Culture name. Your app probably doesn't use some of the more arcane things in the en-GB culture that wouldn't apply to Hong Kong.
Note: In case there is any confusion, for date formatting Thread.CurrentUICulture has no effect whatsoever--it's entirely dependent on what Thread.CurrentCulture is set to (and which must be a specific culture, unlike CurrentUICulture for which a neutral culture such as "en" is OK).
As far as I know you can't combine your culture strings yourself (meaning, en-HK is not valid unless it is listed in .NET).
However, they have two different culture settings per thread:
System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentUICulture
Which both controls different things. Maybe that can let you use english as language but HK as localized formats.
You could also override the formatting of dates and such specifically, and maybe find better cultureinfos that will give you the date format that you need.
Related
i've started using Bing API translator. all the things is ok but when I tried to translate to it with culture code 'fr-ca',fr-FR then it is translating only using language code 'fr' not with culture code (ca, FR) 'fr-ca', 'fr-FR'.
When I called this API method to translate
translationQuery.Execute().ToList();
throws this exception :
--------An error occurred while processing this request.
and the inner exception is :
--------"Parameter: To has an invalid pattern of characters"
source : System.Data.Services.Client
can any one help me about this problem? and tell me how to translate text with culture code with anyway either API or something else ?
Thanks In advance
sunil
Thanks for your response.
I have more than 10 files and each files have 1000 words that needs to transalate into another languages on bases of culture code not only language code.
English en-GB British English
en-US American English
en-CA Canadian English
Spanish es-ES Castilian Spanish (as written and spoken in Spain)
es-MX Mexican Spanish
es-AR Argentine Spanish
es-CO Colombian Spanish
Portuguese pt-PT European Portuguese (as written and spoken in Portugal)
pt-BR Brazilian Portuguese
Chinese zh-CN Mainland China, simplified characters
zh-TW Taiwan, traditional characters
zh-HK Hong Kong, traditional characters
Instead of doing translation manually is there any others way to translate e.g(es-ES,es-MX,es-CO, es-AR ) ?. since its langauge code is same for all eg:-(es) but have different culture code for each languages. So it may be case that some words have different meaning in es-es and have diffent means in es-MX, es-Co etc.
it would be helpful if found a way to translate on bases of culture code?
Thanks in Advance
Sunil
The reason is that Bing translator doesn't support Canadian French, only Standard French:
http://msdn.microsoft.com/en-us/library/hh456380.aspx
Microsoft Translator continually adds to the list of supported languages for the Translation and Text to Speech methods. You can always obtain the current list of available language codes using the
GetLanguagesForTranslate() or GetLanguagesForSpeak() methods. These methods will return a language code. You can translate that language code into a friendly name in any of the supported languages using the GetLanguageNames() method. Below are the friendly names in English - you can retrieve them in any of the listed languages using GetLanguageNames(). Here is the list (as of February 2014):
...
fr French
If you want to use Canadian French, you'll have to perform the relevant word swaps afterwards manually.
Ss an aside, Google Translate also only supports Standard French.
I have a software developed in C#, which is a pure sentefic application. Howver the German users found this software stopped working from time to time, when it is installed on German computers. The temporary solution is to change the Language setting in the control panel, and it works fine after we change the language setting from German to English. This is just a kind of engineering sofware, and the software have nothing relalted to the German or English language. Also, as suggested from other posts in msdn, I have checked the "InitializeComponent()" in the source does several times. There are not strange codes in the "InitializeComponent()" function.
When you change locale, you change the meaning of ',' (comma) and '.' (full-stop) when used in numbers. Could it be that you are trying to parse text containing these characters into numbers?
Does your program attempt to initialize numeric fields with formatted numbers, perhaps?
You need to make sure that your code is sensitive to the user's culture when parsing and formatting text. You also need to make sure you use a consistent culture (e.g. the InvariantCulture) when reading data stored to file or sent over a network.
If you are using .NET Framework 4.5, you might be interested to read about the CultureInfo.DefaultThreadCurrentCulture Property.
In the .NET Framework 4 and previous versions, by default, the culture
of all threads is set to the Windows system culture. For applications
whose current culture differs from the default system culture, this
behavior is often undesirable.
The examples and their explanations on the page could be quite helpful for your issue.
Also, as a side note, try{...}catch{...} blocks are always welcome.
My Question
If you want to display Pinyin for Chinese-speaking users, in what "resource file" would you store the Pinyin translation?
Since Pinyin is NOT a "language" per se, but a Latin representation of Chinese characters, it does NOT have a culture code in .NET.
My guess is that we probably need to use the applicable "zh-" (Chinese) cultures and simply place the latin character Pinyin translation inside those resource files.
I apologize in advance if this is a stupid question, but all the different culture stuff is scrambling my brain!!
Background
We're finally getting around to Internationalization of our Web sites. We're handling most of the "Western" cultures okay now (Latin alphabet: "es", "fr", "de") and the different date/number formats. However, the ideogram-based writing systems like Chinese are a challenge due to various legacy systems not handling Unicode. As a short-term workaround, our business area decided to use Pinyin for Chinese speaking users.
So... the business area asked me to "just add a Pinyin resource file" to the site.
The Microsoft culture code is in the format of :
"language-country"
So, take Chinese for example. The code for Chinese is "zh". However, there are many countries and regions that use Chinese, so we append a country code to the language code. "zh-cn" stands for Chinese-Mainland China. Similarly, "zh-tw" represents Chinese for Taiwan.
.Net uses the concept of resource fallback, where resource lookups begins at the level specified and as long as the resource is not found, a less specific resource will be looked at until we get to the default resource. So ideally, the "zh-cn" resource file should contain only resources that are specific to Mainland China. All resources that are common to all Chinese speaking countries should reside in the "zh" resource.
So getting to your question, I believe Pinyin is primarily used in mainland China, and since you are using it as a Chinese translation substitute, I would place the Pinyin translations inside the "zh-cn" resource file.
I have a report choosing start date and end date.
I tested at the office and it is working fine.
When it is installed at the user's place, the following error pops up.
I wonder why is that?
I bring back the database and run at the office.
Still working fine.
Well, it's not a parsing problem in DateTime.Parse, which is what I first expected. Your code (Form1.Calculat) is calling the constructor directly, so you should be able to log what values you're trying to use to create the DateTime, along with which row of the database is causing the problem.
We can't really do any of that diagnostic work for you, but once you've worked out what the values are, you should look through your code to work out where they're coming from.
Does your client have a different default culture to your development machine? That's normally the first port of call - but unless you're manually parsing date/time strings into their constituent bits, I wouldn't have particularly expected this failure mode.
If you could post some code, that would really help.
Are you passing the values to the TimeToTicks method ?
Probably these values are not forming a valid DateTime. Why it works on your office PC might be because you have different culture settings.
For example, in one culture "11/25/2010" is a valid date as the format (MM/dd/yyyy), but on a different culture, where date format is set as (dd/MM/yyyy) it will not be a valid date.
You can change the system date format from the control panel or modify your code accordingly. Hope this helps.
I think it is most of a problem Culture specific rather than any other issue. At one system the date format would be MM/DD/YYYY and at other system it would DD/MM/YYYY or something like that. So the datetime object should be picked culture specific and values should be passed that way as well.
Hope it fixes the problem.
I have bunch pages and I need to validate data there. If culture for example "es-ES" I should use one validation logic, if culture "en-US" than another validation logic. For example I need validate phone number. Minimum length is 11 digits. For other culture 9 digits. How can I do this? Some patterns or other decisions?
If localizing, you should be using satellite assemblies for localization - this will also allow you to set culture specific RegEx expressions for validation (phone number formats etc).
You can determine the current culture by checking Thread.CurrentThread.CurrentCulture.Name. Is that what you mean?
What if my browser is set to en-US because I'm a us national but I'm in spain with a spanish mobile number?