Get currency symbol from currency/country code - flutter

I have my app translated to different languages (https://pub.dev/packages/flutter_translate) and I also provide the option to select a specific currency (https://pub.dev/packages/country_currency_pickers):
first 2 options
When I select the currency I get this:
Now that everything is selected I need to update my currency and for that I can do:
NumberFormat.simpleCurrency(
locale: "en_GB",
).format(money);
Notice that I have en_GB which is what I'd need here to display pounds. For this example I get es from the language and GB from the currency but es_GB gets euros instead of pounds, which is what I'd need.
How can I get the country code from any of the previous parameters?
Can I pass something else to get the symbol like currencyCode for example?

You should use provide name in the constructor. https://api.flutter.dev/flutter/intl/NumberFormat/NumberFormat.simpleCurrency.html
If name is specified, the currency with that ISO 4217 name will be used. Otherwise we will use the default currency name for the current locale.
NumberFormat.simpleCurrency(
name: "GBP", //currencyCode
).format(money)

Related

create a dynamic title that displays date range as per the start and enddate parameters used

I have a report that displays monthly and ytd amounts. I use start and enddate parameters that change according to the user. For example for startdate 4/1/2007 and enddate 2/28/2008
1. I need to display title as Monthly budget 2/1/2008 to 2/28/2008
2. I need to display title for YTD as YTD 4/1/2007 to 2/28/2008
I tried = Parameter!EndDate.value but it throws error
It looks like you may have missed a letter in your expression. It should be:
=Parameters!EndDate.Value
In the expression editor you can double click on the parameter name and it will insert it into the expression for you.
To get the full description that you mentioned, you'll need to use a combination of functions. One useful one to look at is DateAdd to add days and months to the specified date. Another one is FormatDateTime which allows you to use the standard "ShortDate" format.
If you run into further trouble, I would recommend posting a new question with the variations of code that you tried along with the specific error messages that you received.
You could try setting the Expression for a text box to:
="Monthly Budget " & FORMAT(Paramters!StartDate.Value, "MM/dd/yyyy") & " to " & "FORMAT(Paramters!EndDate.Value, "MM/dd/yyyy")
This will give you:
Monthly Budget 02/01/2008 to 02/28/2008
It is the same for your second requirement, just change the wording.

Yii global date format (l18n)

When I type:
Yii::app()->getLocale()->dateFormat
it gives me the correct dateformat for the current set language. (in my example it is 'de' => dd.MM.yyyy). But when I type:
Yii::app()->format->dateFormat
Yii gives me the date format for 'en_us' (Y/m/d).
With getLocale() I will get only the string saved in i18n file. In ->format->date() this format string should be used, but I don't find a way to assign the i18n string to the CDateFormatter or CFormatter Object.
The CFormatter component accessed with Yii::app()->format is not meant to be used for localization out of the box; it does not automatically work according to the application locale.
You could manually change the relevant properties on Yii::app()->format to bring it in line with the application locale, but there is a more convenient way to format dates:
Yii::app()->locale->dateFormatter->formatDateTime(...)
See CDateFormatter::formatDateTime for more information; if you want more control, there are other methods such as CDateFormatter::format available. Also keep in mind that CLocale::getNumberFormatter() is available to format numbers.

number format on Zend Currency

I am developing a site Zend based but I have the followin problem:
$currency = new Zend_Currency();
$currency->toCurrency(20, array('currency' => 'EUR','number_format' => '#0.#'));
Gives me 20,00 EUR but I need 20.00 EUR (that is why i set number_format), Any suggestion?
Try changing number_format to just format.
Excerpt from Zend_Currency Docs in reference to the options array('format' =>'#0.00'): format: Defines the format which
should be used for displaying numbers. This number-format includes for
example the thousand separator. You can either use a default format by
giving a locale identifier, or define the number-format manually. If
no format is set the locale from the Zend_Currency object will be
used.

Customizing phone number or any other String for different Locales in GWT

I am trying to find the best route to get in some Custom formats I need. For example if I have a phone number 0803456765
In India it may be represented as +91 (080) 3456765
In US it may be 080-345-6765 and so on
I could keep the format in the properties file and based on locale I could pull the format and format the String. I could also have a Util class which does this for me after I identify the Locale.
But I think there might be a better route using NumberFormat. I guess NumberFormat automatically figures out the Locale and applies a certain Pattern to the String. Can I customize this pattern ? In the sense, can I tell GWT to use my Custom pattern for the US Locale
I know we can do this
// Custom format
value = 12345.6789;
formatted = NumberFormat.getFormat("000000.000000").format(value);
// prints 012345.678900 in the default locale
GWT.log("Formatted string is" + formatted, null);
but I don't want to specify my formatting pattern as in 'NumberFormat.getFormat("000000.000000")'. I want to override the default number formats of various Locales in GWT to achieve this. How do I do this ?
Don't roll your own. Google open sourced their library which you can leverage. It supports
Parsing/formatting/validating phone numbers for all countries/regions
of the world.

format currency for specific local in obj c

i am getting product price in multiple currency. here is a sample data
CurrencyName CurrencySymbol Pirce
"USD", "$" 1234.5
"EUR", "€" 12340.5
"GBP", "£" 123.4
"CHF", "CHF" 12345.0
so i want to format available currency based on type not based iPad/iPhone local format.
for example
$1234.50
1.234,50€
and also i want to display all at a same time.
thanks.
That means you want to show it in different localizations. Like the Euros in French or German (with decimal comma) and the CHF in Swiss (with decimal point and probably and apostrophe for separating the thousands).
I would map the currency to a specific localization and the feed it to the nsnumberformatter.