Unable to change locale settings
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Unable to change locale settings
How would you change the decimal separator? I tried:
but this doesn't change anything.
Also, Swiss Francs are correctly shown as "CHF" in the backend, but in "Fr" in the frontend. How would you change this? I tried:
none of the two lines worked.
Then, how can I place the currency symbol in front of the price? I tried this as indicated here https://aimeos.org/docs/Developers/Html ... pe_formats:
didn't work either.
Code: Select all
'client' => [
'html' => [
'common' => [
'format' => [
'separatorDecimal' => '.',
]
],
]
]
Also, Swiss Francs are correctly shown as "CHF" in the backend, but in "Fr" in the frontend. How would you change this? I tried:
Code: Select all
'i18n' => [
'de' => [
'client/currency' => [
'CHF' => 'CHF',
'Fr' => 'CHF',
],
],
],
Then, how can I place the currency symbol in front of the price? I tried this as indicated here https://aimeos.org/docs/Developers/Html ... pe_formats:
Code: Select all
'i18n' => [
'de' => [
'client/code' => [
'price:default' => ['%2$s %1$s'],
],
],
],
Re: Unable to change locale settings
I just found out, that the last example actually works and places the currency code before the price. However only on the product, not in the basket.
Re: Unable to change locale settings
The decimal separator is determined automatically by the locale setting due to the NumberFormatter class of the php-intl extension. You can't change that any more:
https://github.com/aimeos/aimeos-core/b ... Locale.php
The old view helper is still available but not used any more:
https://github.com/aimeos/aimeos-core/b ... andard.php
Use this configuration:
Code: Select all
'i18n' => [
'de' => [
'currency' => [
'CHF' => 'CHF',
],
],
],
This is the correct setting but keep in mind that the basket content is cached and only renewed if the basket is updated. You can disable caching the basket for development using this setting:flomo wrote: ↑24 Oct 2019, 18:27 Then, how can I place the currency symbol in front of the price? I tried this as indicated here https://aimeos.org/docs/Developers/Html ... pe_formats:
https://github.com/aimeos/aimeos-larave ... op.php#L65
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Unable to change locale settings
Thanks for your always very appreciated support!
It would be great to have a formatting column for each locale in the backend in a future version.
In Switzerland we have 4 languages ((Swiss-) German, French, Italian and Rumantsch). Because its difficult to support all of them, we often add English to German and French. It's also not so easy to find translations in de_CH, that's why it's often easier to simply use the "de" locale (same goes for fr/fr_CH). NumberFormatter generates a different format for en, fr, de, fr_CH and de_CH (the latter two being the correct ones). I will have to find a way to somehow hardcode the formatting, no matter the locale.The decimal separator is determined automatically by the locale setting due to the NumberFormatter class of the php-intl extension. You can't change that any more:
It would be great to have a formatting column for each locale in the backend in a future version.
I had to use the following, because Aimeos treated the string as an array:Use this configuration:
Code: Select all
'i18n' => [
'de' => [
'currency' => [
'CHF' => ['CHF'],
],
],
],
I had it disabled and also cleared the cookies. But no matter what I do, I can't update the formatting in the basket. It reads "Versandkosten 0,00 CHF" while the product reads "ab 1 CHF 123,00 Inkl. 7,70% MwSt.". When I switch the locale to "en", value and currency are switched, but I can't influence it: "Shipping CHF 0.00".This is the correct setting but keep in mind that the basket content is cached and only renewed if the basket is updated. You can disable caching the basket for development using this setting:
Re: Unable to change locale settings
I just played around with the helpers. Is there a possibility to overwrite or exchange them?The old view helper is still available but not used any more:
Re: Unable to change locale settings
You can by creating your own view object in your service provider and extending/overwriting the method in the original view object:
https://github.com/aimeos/aimeos-larave ... hp#L82-L84
The easier way might be to use the pattern configuration for the NumberFomatter class: https://github.com/aimeos/aimeos-larave ... w.php#L162
Then, you can use configure patterns like "#.###.##0,00" to get always the same format:
https://unicode-org.github.io/icu-docs/ ... ml#details
https://github.com/aimeos/aimeos-larave ... hp#L82-L84
The easier way might be to use the pattern configuration for the NumberFomatter class: https://github.com/aimeos/aimeos-larave ... w.php#L162
Then, you can use configure patterns like "#.###.##0,00" to get always the same format:
https://unicode-org.github.io/icu-docs/ ... ml#details
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Unable to change locale settings
Aimeos also has a fallback for translations from de_CH/fr_CH to de/fr. We will keep your suggestion in mind to add configure number formats per locale in the future.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Unable to change locale settings
That would be great.Aimeos also has a fallback for translations from de_CH/fr_CH to de/fr. We will keep your suggestion in mind to add configure number formats per locale in the future.
This doesn't work, because a dot is always the decimal separator, which will get localized. So "#0.#" will produce a comma with locale "de" and a dot with locale "de_CH".The easier way might be to use the pattern configuration for the NumberFomatter class:
Then, you can use configure patterns like "#.###.##0,00" to get always the same format:
I now register my own instance of \Aimeos\Shop\Base\View which overwrites the addNumber() method with a custom Locale helper. This works so far.
However I'm still stuck with the currency formatting in the basket. This
Code: Select all
i18n\de\client/code\price:default = ['%2$s %1$s']
Re: Unable to change locale settings
Would "#'###'##0.00" produce the desired result? I'm asking because you have to get the desired results with one of those patterns. Otherwise, it's useless to add locale specific formatting.
Use that one for the basket and the order to reverse currency and value:flomo wrote: ↑28 Oct 2019, 10:55 However I'm still stuck with the currency formatting in the basket. ThisCode: Select all
i18n\de\client/code\price:default = ['%2$s %1$s']
Code: Select all
'i18n' => [
'de' => [
'client' => [
'%1$s %2$s' => ['%2$s %1$s']
]
]
]
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Unable to change locale settings
No, it doesn't work like this. With the pattern you can set the number of digits after the decimal separator, for example. But you can't define what the separator looks like. The idea of the NumberFormatter pattern is to define a pattern for a number, which then still gets localized. So the decimal separator will always be a comma for "de" and a dot for "de_CH", no matter the pattern.Would "#'###'##0.00" produce the desired result? I'm asking because you have to get the desired results with one of those patterns. Otherwise, it's useless to add locale specific formatting.
That worked, thank you very much.Use that one for the basket and the order to reverse currency and value: