How to add a space after currency symbol in CakePHP (3.0)? - cakephp

The question is actually pretty simple. I have the following code to display my currency on my page. $this->Number->currency($HdViewBestellingen->INKBLPRIJS, 'EUR') This prints out the curreny like:
€0.12
But I want the currency to print out like:
€ 0.12
(notice the space between the € symbol and the number).
My question is, how do I achieve this using the CakePHP number formatter?
After reading http://book.cakephp.org/3.0/en/core-libraries/number.html#formatting-currency-values.
I have been messing around with the options array which can be passed as well like $this->Number->currency($HdViewBestellingen->INKBLPRIJS, 'EUR', ['pattern' => '#, ####.##']) but I couldn't get it to work.

It depends on the locale you are using. The locale also controls the position of the symbol.
If you use en_US then there are no spaces between the symbol and the number.
I suggest you to use any of the european locale. If you don't want to change it at application level in bootstrap.php you can set it just for one occurence like so
$this->Number->currency($HdViewBestellingen->INKBLPRIJS,'EUR', ['locale' => 'it_IT'])
I used italian locale because if you use german locale the euro symbol comes after the number

Related

moment js not properly translating the date format for japanese locale

I need to translate the date format to Japanese locale but its showing output wrongly.I also tried by changing the locale of the browser but its not working in both chrome and IE
app.filter('japan', function() {
return function(dateString, format) {
return moment().locale('ja').format('LLLL');
};
})
Output for the format is 2016蟷エ6譛�20譌・蜊亥燕11譎N蛻� 譛域屆譌・
Required output is 2016年6月20日午前11時30分 月曜日
This isn't an issue with Moment. It's an encoding problem known as mojibake and can happen when your page has an encoding that doesn't correctly handle the characters you are using. In general, it's preferable to use a neutral encoding like UTF-8 or UTF-16 (UTF-8 is the de-facto standard), and from the comments above, it sounds like this did indeed fix your issue.
Additionally, it is a good idea to set a lang="" attribute on the element containing your localized content (you can do this as high up as the <html> element), because certain characters can have different appearances depending on the locale.
To take your text as an example, the top-right portion of the character 曜 looks like 羽 with lang="zh", but looks like two side-by-side ヨs with lang="jp".

Localizing a currency range

A combination of formatjs & javascript's native Intl.NumberFormat() supports formatting of numbers as currency in various cultures and units. But how can I format a range of currency as $1,000.00 - 5000.00.
Without repeating the symbol, where ever and however it is normally displayed?
Using react-intl:
<FormattedNumber value={minVal} style="currency" currency="USD" />
- <FormattedNumber value={maxVal} style="currency" currency="USD" />
This will show $1,000.00 - $5000.00 which does not match my design spec. Stripping away the currency symbol off of the second value seems like a hackey strategy since I shouldn't/can't easily know the symbol to strip.
Formatting just as a regular decimal would be strictly incorrect - currency rules dictate different numbers of digits for the "minor units" depending on the currency.
And what about if the currency symbol is, I don't know, displayed at the end for the culture instead of at the beginning? (Does that happen?)
How about something like numeral.js? The locales documentation seems like it could do what you're looking for. They have a number of locales already and are happy to welcome more as contributions.
Update: looks like someone already created an Angular integration too.

CakePHP: CakeTime i18nFormat for date and time

I'm using the CakeTime class for my localization of dates & times.
For dates it works like I want it to:
$timestring = $this->Time->format('Y-m-d H:i:s', time());
echo 'DateTime: '.$this->Time->i18nFormat($timestring);
// Result => DateTime: 11/08/2013
I want it to also display the time.
For example in the US they use AM/PM and in other places they use the 24 hour notation.
I've looked but can't seem to find a way to do this.
Any idea's?
Edit*
To be clear, the localization works perfectly for the dates(have the LC_TIME files), but the i18nFormat function only returns the date, and from what i saw, passing a format will use that format, not the localized one, example MM/DD/YYYY vs DD.MM.YYYY in a different locale
*Edit2:
The solution vicocamacho gave in the comments is the correct one
So to get the Date + Time in the localized form:
$this->Time->i18nFormat(time(), '%x %X') does the trick!
You can use the TimeHelper::i18nFormat method. You also can check this repo to find common date/time translations https://github.com/cakephp/localized be sure to store them in the APP/locale/<locale>/LC_TIMEdirectory

Getting a currency format pattern from AngularJS filter

I'm interested in creating a filter that would accept an amount, ISO 4217 currency code, and fraction size, and return the amount in that format. I noticed that AngularJS has goog.i18n.currency.getGlobalCurrencyPattern in i18n/closure/currencySymbols.js, but I'm relatively new to Angular and not sure if it is possible to use it?
The currency pattern and symbols are just that. It determines how to display a number. It will not convert it from XXX to XXX. You will have to do the converting part based on the current conversion rates.
As far as using the built-in currency formatting, there are multiple ways: in the template, in the code.
In the template:
<div>{{myCurrencyValue | currency:'XXX'}}</div>
In the code:
var formatted = $filter('currency')(myCurrencyValue, 'XXX')
In both cases, 'XXX' is optional [and is symbol] and will use the default currency for current locale
Example: http://jsfiddle.net/TheSharpieOne/N7YuP/
More information can be found here: Currency Docs
UPDATE
Example with ISO 4217 codes using custom filter: http://jsfiddle.net/TheSharpieOne/N7YuP/3/
Note: ISO 4217 doesn't dictate the currency symbols, I used this for symbol reference and mapped them.

What is ↓ and &uparr; equivalent in Winforms?

I'm working on a legacy vb.net winform app, and would like to have have up and down arrows within my button controls.
I would think i need to invoke some sort of escape character sequence to have get the equivalent of &uparr; and &dnarr; ?
Open up "Character Map" (from Programs->Accessories->System Tools on WinXP). You can find all sorts of interesting characters there.
Sometimes, you'll want to use weird fonts like WebDings or WingDings, but be careful to only use fonts that will be on the users's machines.)
You can press ALT and type the unicode value for the character you want. Consult this table, specifically the "arrows" section, and convert from HEX to DEC.

Resources