Achieving numeric and special character internationalization in angularjs application - internationalization

How to implement internationalization in angularjs?
How to achieve multi language support including numeric(0 - 9) and all the special characters like - .,#$& etc. in angularjs application?
For exapmle - Suppose user has selected Chinese as the preferred language from application settings.
So I need to display him numeric data eg - $123,23.01 in Chinese.
Also here in $123,23.01 after $123 I have comma(,) but in Chinese the separator like comma(, and .) are different.
If anyone could share fiddle link of working copy or any clue, it will be a great help.
Thank you .. :)

I could solve it using JavaScript's native method number.toLocalString.
var number = 123456.789;
// request a currency format
console.log(number.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' }));
// → 123.456,79
€

Related

How do I prevent Turkish letters from dropping when using UIFont in cocos2d?

I'm doing the following to create a label that I use as part of attribution for a photo:
CCLabelTTF *imageSourceLabel = [CCLabelTTF labelWithString:[_organism imageSource] fontName:[[UIFont systemFontOfSize:12] fontName] fontSize:12];
Several of the image sources include Turkish letters. For example, in this URL:
http://commons.wikimedia.org/wiki/File:Şahlûr-33.jpg
This displays improperly in my iPad app; the Turkish letters are missing.
How do I create a label that will work with text like that in the URL above?
Edit:
Nevermind... the problem is with exporting from Excel. See the comments on the answer below. This link provides some additional information: Excel to CSV with UTF8 encoding
Additional Edit:
Actually, it's still a problem, even after I export correctly and verify that I have the proper UTF-8 (or is it 16?) letters in the CSV file. For example, this string:
Dûrzan cîrano / CC BY-SA 3.0
Is displayed like this:
and this string:
Christian Mehlführer / CC-BY 2.5
is displayed like this:
It's definitely being processed improperly upon import, as CCLOG generates the following:
Photo Credit: Dûrzan cîrano / CC BY-SA 3.0
More Info:
Upon import, I'm storing the following value as a string in an array:
"Christian Mehlf\U00c3\U00bchrer / CC-BY 2.5"
Wikipedia says the UTF-8 value for ü, in hex, is C3 BC. It looks like the c3bc is in there, but masked as \U00c3\U00bc.
Is there any way to convert this properly? Or is something fundamentally broken at the CSV import level?
The solution is below.
There were several problems:
Excel on the Mac doesn't export UTF-8 properly. The solution I used was to paste the data into Google Spreadsheet and export from there. More info here: Excel to CSV with UTF8 encoding
I realized that once I had the proper data in the CSV file, that I was importing it with the improper settings. I'm using parseCSV and needed to set _encoding in the -init method to NSUTF8StringEncoding instead of the default, NSISOLatin1StringEncoding.
if you try this:
[CCLabelTTF labelWithString:[[_organism imageSource] stringByUnescapingHTML] fontName:[[UIFont systemFontOfSize:12] fontName] fontSize:12];
it will likely work better. I suspect your url string is escaped HTML.

Datetime format not working with slashes Kendo UI

My web application has support for multiple datetime formats, namely yyyy-MM-dd, yyyy.MM.dd, dd/MM/yyyy and MM/dd/yyyy. The two first ones work perfectly, however, when I use the other two formats, the slashes are replaced with dashes in the initial print, which makes them fail validation. However, if I choose a date, it comes out with the correct (chosen) format.
I am using culture sv-SE.
I suspect (with no experience of Kendo UI, but with experience of other date/time APIs) that "/" is being treated as "the culture-specific date separator". If you want "exactly a forward slash, regardless of culture" you may need to escape it.
How the escaping is performed will depend on the library, but often you'd just use quotes, e.g.
dd'/'MM'/'yyyy
MM'/'dd'/'yyyy
As Jon notes in his answer this is about / being a special character in .NET custom date formats.
When working with Kendo this is confusing because it does not use / as a special character.
Using separate format strings client and server side should be the answer, but unfortunately in Telerik UI for MVC (which uses Kendo on the client side) a single format string is used both client and server side with the MVC helpers for Kendo.
For example on a server with a date format "dd-MM-yyyy" (set in Windows regional settings), and a view model:
[Display(Name="Date")]
[UIHint("Date")]
[DisplayFormat(DataFormatString = Constants.DateFormat, ApplyFormatInEditMode = true)]
public DateTime Date { get; set; }
(Constants.DateFormat is "dd/MM/yyyy") then having an editor template ("Date.cshtml"):
#(Html.Kendo().DatePickerFor(m => m)
leads to an initial date display "29-05-2015" and JavaScript errors as it cannot be parsed.
As a work around using
#(Html.Kendo().DatePickerFor(m => m)
.ParseFormats(new[] { "dd-MM-yyyy", Constants.DateFormat}))
the format in the generated HTML is wrong, but the JavaScript will at least be able to understand it. (This should make use of DateTimeFormatInfo.DateSeparator to build the alternative format dynamically of course.)

How can I convert a String with \xf6 chars into a human readable one?

Currently I'm working on an Rails application with PayPal checkout. PayPal communicates with my app with IPN messages.
In many cases everything works fine, but if someone uses special chars like German umlauts (öüäß) I get \xf6 in the string.
How can I convert this into the human readable char 'ö'?
The problem is that the data was encoded as Windows-1252, but ruby won't detect that automatically. You can coax it like this:
my_string = "Sch\xF6ning"
my_string.force_encoding('windows-1252').encode('utf-8')
=> "Schöning"
You can make a reusable converter to help you do the same thing:
ec = Encoding::Converter('windows-1252', 'utf-8')
ec.convert(my_string)
=> "Schöning"
Note that there is a setup on paypal side for that:
In the seller paypal account go to : Profile > My selling tools > PayPal button language encoding > More options

C# MVC3 and non-latin characters

I have my database results (áéíóúàâêô...) and when I display any of this characters I get codes like:
á
My controller is like this:
ViewBag.EstadosDeAlma = (from e in db.EstadosDeAlma select e.Title).ToList();
My cshtml page is like this:
var data = '#foreach (dynamic item in ViewBag.EstadosDeAlma){ #(item + " ") }';
In addition, if I use any rich text editor as Tiny MCE all non-latin characters are like this too.
What should I do to avoid this problem?
What output encoding are you using on your web pages? I would suggest using UTF-8 since you want a lot of non-ascii characters to work.
I think you should HTML encode/decode the values before comparing them.
Since you are using jQuery you can take advantage of the encoding functions built-in into it. For example:
$('<div/>').html('& #225;gil').html()
gives you "ágil" (notice that I added an extra space between the & and the # so that stackoverflow does not encode it, you won't need it)
This other question has more information about this.
HTML-encoding lost when attribute read from input field

Visual basic handle decimal comma

I'm trying to save variables into text files and the Czech typographic rules drives me crazy.
The program I'm tuning is dedicated to work on Czech localized computers where decimal comma is used but the VB is working with normal, standard decimal dot.
When loading files "US" decimals are loaded correctly and showed as Czech decimals. In TextBoxes "Czech" decimals are required. My problem is that program generates Czech decimals and require the "US" ones.
How can I force VB program to read comma as decimal sign instead of delimiter or how to export data with dots instead of commas?
Yes I can load 123,456 as a=123 and b=456 and then return value as a + b/1000 but is there more elegant solution?
Pick the right function.
Val, Str will always use US settings (dot as decimal)
CDbl, Format will take account of the regional settings.
It's all in the manual section on international programming.
Your trouble might be due to use of the Val function; that isn't international. The help text recommends the use of CDbl when converting from strings to numbers.
Thanks for your advices, I'm not sure if I did something wrong, but I've obtained only errors (ie. type mismatch) or "Czech" decimal comma.
I've tried 'Got slapped? Slap him harder!' aproach with this code:
Dim PpP As String, SaveFile As Integer
PpP = Form1.TxtA10.Text & " " & Form1.TxtA11.Text
PpP = Replace(PpP, ",", ".")
Print #SaveFile, PpP
edit:
something means trying those functions at the output, not at the input. (like trying Double as String parameter).
This code:
Input #1,TempString
Form1.TxtA10.Text = CDbl(TempString)
works aswell.
Try,
Format$(CDbl(Text1.Text), "#,##0.00")

Resources