I have some dynamic elements in my Shopify theme, for which I want to display prices in the correct currency and locale. There is Shopify's Shop.moneyFormat, which I can use, but the documentation doesn't say which values it can take. So far I encountered ${{amount}} or €{{amount_with_comma_separator}} but is the first symbol always the currency symbol or are there other variants as well?
Is it generally a good idea to get the currency from Shop.moneyFormat, the language from location.pathname and then use Intl.NumberFormat to format the string?
Related
We're having some difficulty with the provided formattedValue of the Product's Price.
Having USD, for example as the active currency.
The Product's formattedValue is of this format: US$421.08
How do we catch this exact format in frontend?
Is there an available spartacus method that translates a value with the assigned format?
Angular's currency pipe doesn't do the trick either.
I only managed to display it as $421.08
You can create your custom pipe https://angular.io/guide/pipes#custom-pipes and handle the logic on what you want it to be displayed.
For example, pass in the formatted value and the current currency iso string taken from currency.service - getActive() to concat both to display US$421.08, or any other mutation.
Hello!
Since the 1.7 update of PrestaShop you cannot customize the currency any longer. In my theme by default, the currency symbol displays right before the numbers, without any space. But it should be exactly opposite, symbol after the numbers with a space between them. If anyone knew a way around I would be very grateful.
I could explain here, but there are a lot of tutorials in the web, which I think can be more useful, here one to change the symbol: https://zemez.io/prestashop/support/how-to/prestashop-1-7-%D1%81hange-currency-symbol/
If you want to change the position of the symbol, you need
Go to translations/cldr/main--xx-XX--numbers file (where xx-XX is your language, en-EN, de-DE or ru-RU). Open this file with any code editor.
Find something like this "accounting":" and "standard" and move the \u00a0 to the start or end, depending on where you want to place the symbol.
For example I will move the symbol from the start to the end en-US numbers.
Before: "accounting":"\u00a4#,##0.00;(\u00a4#,##0.00)","standard":"\u00a4#,##0.00"
After: "accounting":"#,##0.00\u00a4;(#,##0.00\u00a4)","standard":"#,##0.00\u00a4"
Hpe this help!
If somebody searching for changing currency sign on PS 1.7.6.
Now it is in the table ps_currency_lang
Via admin panel cannot be changed at the momen, only phpmyadmin :(
I am working on a ASP.NET MVC app.
This app displays a detail information regarding a product.
The product name can have any special chars like single quote, the percentage symbol, the Registered symbol the one with a circle and 'R' inside, the Trademark symbol etc.
Currently all these are replaced with a '-'.
If the name is like this:
Super - Men's 100% Polyester Knit Shirts
It appears like this in the URL:
8080/super---men-s-100-polyester-knit-shirts/maverick
- men-s-100-polyester-knit-shirts
This is done in Js like so:
Name.replace(/([~!##$%^&*()_+=`{}\[\]\|\\:;'"<>,.\/? ])+/g, '-').replace(/^(-)+|(-)+$/g, '');
So the question is, should the name be displayed as-is in the URL?
If yes, some pointers please.
If no, please provide some valid reasons like standards as followed today that will help me put the point across the table.
Regards.
The short answer is not to fiddle with it. It's as good as it gets out of the box.
The Url can only contain a small number of alphanumeric letters. which basically means you can only have 0-9 a-z and - _ . ~.
All other characters need to be encoded. Now that you can have arabic url's too it has gotten a little more complicated.
But assuming your website is indo-european this is it. So you will never be able to have full product names in your url.
And renaming them as something more cool like replacing % with "percent" in the url can bring desaster upon your url's as in some cases the "fake" names may not end up unique and therefore end up with unreliable routing.
look at URI characters on wiki
i want to use comma separator to display my double value as currency value in WinRT XAML?
like
<TextBlock Text="{Binding Amount, StringFormat={}{0:C}}" />
I need to achieve this in XAML, not in C# using IValueConverter.
Thanks in advance.
Joy Rex
Sounds like something that should be delegated to be handled by the platform, not by some arbitrary format string, doesn't it? I believe this should happen automatically for users using a locale that uses commas as separators such as Polish. I don't have much recent experience with that in .NET, but perhaps a decimal type would make it work if double doesn't. Also remember that you can simply expose an AmountAsString property that is formatted by your view model since you only bind it one-way into a TextBlock anyway. Oh and otherwise - there is nothing wrong with an IValueConverter.
Just to note on this thread, the Windows.Globalization.NumberFormatting APIs are available for both currency and decimal formatting, and automatically applies the user's locale-specific or customized number formats along with currency symbol placement. The Number formatting and parsing sample shows all the variations.
I've looked into NSFormatter, NSNumberFormatter, and the other formatting classes, but can't find a build into solution. I need to format phone numbers depending on the country code.
For instance, for US, I get a string such as +16313938888 which I need to format to look like +1(631)393-8888. The problem is I need to do this for all formats. Netherlands, I receive a string +31641234567 which will be +31(6)41 23 45 67 (something like that).
Hardcoding for 200+ countries is too tedious and I really don't know all the format rules. Is there something in the docs I'm overlooking or does anyone know of an open source class that manages this?
See https://github.com/rmaddy/RMPhoneFormat for an iOS specific solution.
Try this Google solution - https://github.com/me2day/libPhoneNumber-iOS
They have ports for C++, Java, Objective-C and others.
Unfortunately iOS does not have any public APIs for this. You can try to integrate libphonenumber that is a complete implementation for parsing and formatting international phone numbers. It has a C++ version so theoretically you can cross-link with it.
You definitely don't want to hard-code all of the various country formats. There are typically 3-5 formats per country. Instead, use a format database (such as a plist) and write code to format the number based on the given country code.
A good international format property list 'UIPhoneFormats.plist' can be found here: https://code.google.com/p/iphone-patch/source/browse/trunk/bgfix/UIKit.framework/PhoneFormats/UIPhoneFormats.plist?r=7
In that list, '$' allows any character, '#' must be a number, and the '(space) ', '(', ')' and '-' are inserted between numbers. Non-numeric characters typed by the user hint to the desired format.
I've shared my phone number formatter class, inspired by Ahmed Abdelkader's work, at https://github.com/lathamglobal/iOS-Phone-Number-Formatter . It is a very small, single-class international phone number formatter that uses the plist just mentioned.
You can try this:
let phoneNumber : CNPhoneNumber
let digits = phoneNumber.performSelector("digits").takeRetainedValue() as! String
It gives you directly the string, without formatting, with the phone number. However if the number is saved with international prefix, you will have it also in the resulted string.