What culture code should I use for Pinyin? - c#

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.

Related

Bing translator exception from en-us to 'fr-ca'

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.

C# program stops working after the language setting in control panel is changed (say, from English to German)

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.

Localising asp.net app to HK with language set to english

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.

windows phone localization for English countries

I have a question about Windows Phone localization. I checked culture and language support for windows phone, for English, there's only English (United States) and English (United Kingdom). I also want to ad English support for Canada and Australia, so how can I do that? Also The display language setting in emulator only has English (United States) and English (United Kingdom) for English, so how can I test other English countries such as Canada and Australia? Thanks!
Fei
Windows Phone 7 has a limited support matrix right now for culture/language combinations. You can see this language support list on MSDN. I would recommend coding to en-CA for Canada if you desire it.
There's some guidance on how to support non-supported languages in WP7 from Microsoft if you view "How do I localize for a language that isn't supported?" section. You're not going to like it though. Here's the snippet of the steps.
Hard code your app to be written in the unsupported language, if you don't plan on supporting more languages in the future. OR, create
your default AppResources.resx file and put your unsupported language
strings in there, if you plan on supporting more languages in the
future or will support additional languages in your submission.
Set your neutral language to one of the supported display languages. For example, 'English (United States)'.
On App Hub, you will be prompted to input metadata and a description for the neutral language you chose (for the above example,
you'll be prompted for English). You must include the following three
items in the 'Detailed description' field to pass certification:
A note, such as ‘The language of this application is [unsupported
language name]’. This note must be written in the same language as the
neutral language. For example, if you chose 'English (United States)'
as your neutral language, the note must be written in English (United
States). This note must be the first item in the ‘Detailed
description’ field. Your app description, in the same language as the
neutral language. Your app description, in the unsupported language.
I would also recommend sticking it in an en-CA file so you can easily swap to it if/when support comes.

How do I validate for language? ASP.NET

In a textbox in the application, I need to validate to ensure that a user enters only English language text. I know some languages such as Spanish share English's alphabets. How do I validate text to make sure it's:
Only in English language
Supports only languages that use the English character set (Spanish etc)
Thanks
EDIT: Sorry for not being clear enough. This app is on production and when I check the SQL database where the text is stored, there are a lot of rows with "??? ?????". On further investigation, it appears that this is caused when a non english language text is saved to a database. As an example, go to google news, select google Korea from the dropdown, copy some Korean text and save it to a SQL server database
Anyone?
By "English character set", I guess you are referring to the ASCII character set.
You can iterate through each character and see whether it lies in the ASCII range.
You can try to check against an English dictionary (e.g. OpenOffice has a dictionary which you may use for free, not sure about that though) if most of the used words are recognized by this dictionary.
You could also do some kind of text analysis and check the occurance of each character or short sequence like 'th' etc. Each language has specific character occurances and this could help you determining in what language the text is written.
I would not prohibit certain characters because at least in names special characters occur quite often.
I hope you got an idea of some possibilities.
Best Regards, Oliver Hanappi
If this is for a moderately small amount of text, you could try finding an English dictionary web service and try to look up the words. If lookup fails, you most likely either have a typo or something from another language. I haven't found one that accepts large blocks of text, but there is a web service that operates off of the dict.org database:
DictService
One way is to use a English Language Dictionary / Spell Checker , if is valid English / Spanish Word
a very good sample is this
NetSpell Sample - Spell Checker for .NET
It is as simple as follows
NetSpell.SpellChecker.Spelling SpellChecker =
new NetSpell.SpellChecker.Spelling SpellChecker()
SpellChecker.Text = MyTextBox.Text;
SpellChecker.SpellCheck();
NetSpell Home Page: http://www.loresoft.com/NetSpell

Categories