How Ti.Locale.getCurrentLanguage() , i18n defferent? - internationalization

My Tianium application uses i18n.
I have four folders under i18n.
en/ ja/ zh-CN/ zh-TW/
zh-CN is Chinese used in Mainland china.
zh-TW is Chinese used in Taiwan.
it works well for i18n.
Now I want to get this name, in app.js. However, as for Ti.Locale.getCurrentLanguage(), both Taiwan and Mainland china returns 'zh'.
How can I tell zh-CN or zh-TW ???
----Solution----
Thanks to #DC Jmz
use Ti.Locale.getCurrentLocale()
if ( Ti.Locale.getCurrentLocale().match(/zh-Hant/)) {
Ti.App.global.lang = 'zh-TW'; // taiwan letters
}
if ( Ti.Locale.getCurrentLocale().match(/zh-Hans/)) {
Ti.App.global.lang = 'zh-CN'; // mainland china letters
}

Try using Ti.Platform.getLocale()
System's default language.
Locale, as a combination of ISO 2-letter language and country codes. For example, en-US or en-GB. See the ISO 639-1 and ISO 3166-1 alpha-2 sections of wikipedia for reference.

Related

How to localize country names in phrases?

I want to localize phrases like "Places in {country name}" where the country name is dynamically obtained (e.g. by -[NSLocale localizedStringForCountryCode:]).
The problem is that for some country names, an article must be prepended:
Places in the United States (en)
Sometimes in plural form, male or female, capitalized or not:
Lugares en los estados unidos (es)
Lugares en las Maldivas (es)
The article might even have to be declined according to the casus (nominative, dative etc) of the country name in the phrase:
Orte in der Schweiz (de)
Wir fahren in die Schweiz (de for "we go to Switzerland")
Or we even might might a different preposition:
Orte auf den Malediven (de, using "auf" instead of "in" because the Maldives are islands)
Is there either a library or a good set of rules (e.g. regular expression based) that one could use to accomplish this?
While I'm primarily searching for an iOS solution, I'm open to port any solution from other platforms.
This problem is best solved by avoiding it altogether: localise the entire phrases, and key them by the ISO country code.
The reason is that the rules are complex, not necessarily regular, and differ from language to language. Take Russian for example, where the country name itself (as opposed to just a preposition) has to be modified based on the casus in which the word appears in the sentence — I assume the same holds for various other Slavic languages.

Multiple Fonts in writeText() function in 'gm' (graphicsMagick + ImageMagick)?

I am trying to write on image with multiple language. I am using npm package 'gm' .
gm(inputFilePath)
.font(fontFilePath) // .ttf format
.writeText(x,y,TextToBeWritten)
.write(outputFile , callBackFunction())
Here I want to write in Multiple languages. And there is no single font which includes all of them. How can I pass multiple fonts to writeText function ?
Let's say I want to write in Chinese , English , Russian , Japanese and Hindi . How can Pass something like
.font(font1.ttf , font2.ttf , font3.ttf)
.writeText(x , y , TextToBeWritten)
If I can't do this, then I will no other choice, but to merge multiple fonts. and generate single .ttf file.
I would like to do it if it's possible. If it's not possible with current version of 'gm', then I would like to contribute to 'gm'. If anyone can guide me, I might be able to pull it off.

Apache Rewrite mode. Rewrite Rule

Links
http://example.com/en/media/.../img.jpg
http://example.com/en/media/.../style.css
http://example.com/en/media/.../script.js
http://example.com/en/media/.../file.pdf
http://example.com/en/media/.../file.doc
and other extensions...
I need to check extensions (jpg|png|css|js|doc) at the end of query string and remove language (Part beetween http://example.com/ and /media/). I dont know how much and which specific symbols it will have.
en (En, English, En-en, En.en)
ru (Ru, Russian, Ru-ru, Ru.ru)
http://example.com/media/.../img.jpg
http://example.com/media/.../style.css
http://example.com/media/.../script.js
http://example.com/media/.../file.pdf
http://example.com/media/.../file.doc

Magento: Decimal Price in spanish language display Dot instead comma

i have multilanguage store. default language is english. there are few products have decimal price.
when i switch languge to spanish the comma appears instead dot in decimal price.
for example: price: 1.35$ in english when i switch language to spanish the price will look like Price: 1,35$
i really wanna remove this , need . how to do that.?
You could try to change the local settings. So go to your magento directory and open the file lib/Zend/Locale/Data/en.xml (replace en.xml by the language file for which you would like to perform your changes).
Search for
<numbers>
<symbols>
<decimal>.</decimal>
<group>,</group>
Clear the cache, also for safer side please try to do this first on your test installation to avoid issues.
You can change your locale setting
here is example for English. For that you have to do Minor changes in your Language File. >Following is the Directory Structure of File.
=> root/lib/Zend/Locale/Data/en.xml (For English Language)
=> around line 2611 you can see following code.
> <currencyFormat>
> <pattern>¤#,##0.00;(¤#,##0.00)</pattern>
> </currencyFormat>
=> Now Change above code with Following code.
> <currencyFormat>
> <pattern>#,##0.00 ¤;(#,##0.00 ¤)</pattern>
> </currencyFormat>
you can set it to for Dutch.
To fix the comma form 1.000 to 1,000
add to the past post the following :
go to: => root/lib/Zend/Locale/Data/XX.xml (XX.xml For your Language)
for example : => root/lib/Zend/Locale/Data/en.xml (For English Language)
around line 2286 you can see following code :
<numbers>
<defaultNumberingSystem> xxx your Language xxx </defaultNumberingSystem>
<symbols>
<decimal>,</decimal>
<group>.</group>
to :
<numbers>
<defaultNumberingSystem> xxx your Language xxx </defaultNumberingSystem>
<symbols>
<decimal>.</decimal>
<group>,</group>
this wil change the comma form 1.000 to 1,000
thanks & regards
Bahattab

How do format a date/time/number/currency in another locale?

How do i format something for another locale in Windows?
For example, in managed C# code, i would try to render a DateTime using en-US locale with:
String s = DateTime.Now.ToString(CultureInfo.CreateSpecificCulture("en-US"));
TextRenderer.DrawText(
e.Graphics, s, SystemFonts.IconTitleFont,
new Point(16, 16), SystemColors.ControlText);
And that works fine when my computer's locale is en-US:
It even works fine when my computer's locale is de-DE:
But it completely falls apart when my computer's locale is ps-AF:
Note: My sample code is in .NET, but can also be native.
Update: Attempting to set System.Threading.Thread.CurrentThread.CurrentCulture to en-US before calling DrawText:
var oldCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
try
{
// String s = DateTime.Now.ToString(CultureInfo.CreateSpecificCulture("en-US"));
String s = DateTime.Now.ToString();
TextRenderer.DrawText(e.Graphics, s, SystemFonts.IconTitleFont, new Point(16, 16), SystemColors.ControlText);
}
finally
{
System.Threading.Thread.CurrentThread.CurrentCulture = oldCulture;
}
No help.
Nine, no help
Jack, no help
Eight, possible straight
King, possible flush
Ace, no help
Six, possible straight
Dave of love for the dealer
Ace bets.
Update Two:
From Michael Kaplan's blog entry:
Sometimes, GDI respects users (even if no one else does!)
GDI doesn't give a crap about formatting or really anything related to locales, with one single exception:
Digit Substitution
Any time you go to render text it will grab those digit substitution settings in the user locale (including the user override information) and use the info to decide how to display numbers.
And there is no way to override those settings at the level where GDI uses them.
i wonder how Chrome manages it. When i write digits here, in the stackoverflow question, Chrome renders them using latin digits:
0123456789
See:
What you are seeing is due to the digit substitution that occurs when your system's locale is ps-AF.
I believe that's OK -- Users of such a locale are used to seeing digits presented this way.
Normally the way this is done is slightly different, see here for example, but I don't actually think this should make any difference:
String s = DateTime.Now.ToString(new CultureInfo("en-US"));
An alternative is to set Thread.CurrentCulture to your desired locale.
I.e. do this:
Thread.CurrentCulture = new CultureInfo("en-US");
And you can then replace the first line of your code with this:
String s = DateTime.Now.ToString();
I am not quite sure, but I believe that this would solve the digit substitution issue as DrawText would now be based on the en-US culture, rather than ps-AF

Resources