Page 1 of 1

[SOLVED] Incorrect number formatting for Bulgarian

Posted: Sun May 17, 2015 6:58 pm
by cheeseus
This is a problem that hasn't been resolved in many CMS platforms, and will require additional coding.
Here is a description:

In English, where the number is larger than 999, the 'thousand separator' ('thousand point') delimiter is introduced, so that in larger numbers, the digits will be separated in groups of three, e.g. 5,000 and 340,000.

In Bulgarian, however, the thousand separator (a space) is only used for numbers larger than 9999. Numbers between 1000 and 9999 are correctly spelt without a separator, and it is only used for numbers larger than that, e.g. 10 000, 25 500, 500 000.

This results in prices or other units being incorrectly displayed, e.g. the price of a product that costs one thousand two hundred and fifty BGN will be displayed as '1 250', instead of the correct '1250'.

Without being too sure about this, I think the same rule applies to Russian, and possibly to other Slavonic languages.

Re: Incorrect number formatting for Bulgarian

Posted: Sun May 17, 2015 7:06 pm
by OSWorX
Easy to fix.
Just edit the main language file (which maybe in Bulgarian bg_BG) and adopt the value

Code: Select all

$_['thousand_point']        = '.';
to

Code: Select all

$_['thousand_point']        = ' ';

Re: Incorrect number formatting for Bulgarian

Posted: Sun May 17, 2015 7:10 pm
by cheeseus
Please read my original post again.
It is not about what the 'thousand point' is, it is about WHERE it should be inserted.

Re: Incorrect number formatting for Bulgarian

Posted: Sun May 17, 2015 7:28 pm
by OSWorX
cheeseus wrote:Please read my original post again.
It is not about what the 'thousand point' is, it is about WHERE it should be inserted.
Sorry, but what do you expect now from us?
To change to the code for Bulgarian numbers?

Re: Incorrect number formatting for Bulgarian

Posted: Sun May 17, 2015 7:50 pm
by cheeseus
OSWorX wrote:
cheeseus wrote:Please read my original post again.
It is not about what the 'thousand point' is, it is about WHERE it should be inserted.
Sorry, but what do you expect now from us?
To change to the code for Bulgarian numbers?
As I said, I think the same rule applies for Russian and other Slavonic languages as well.
I have now checked with a colleague Russian linguist and he has confirmed the same rule applies. I am not sure about other languages that use the Cyrillic script, but it is very likely that the rule applies there, too.
So the answer is "yes" -- but not just for Bulgarian, obviously -- for Russian as well.

Re: Incorrect number formatting for Bulgarian

Posted: Sun May 17, 2015 8:05 pm
by OSWorX
As a 'starting' point.

Open

Code: Select all

../system/library/corrency.php
search for

Code: Select all

$string .= number_format(round($value, 
and add before

Code: Select all

if( $value < 9999 ) {
	$thousand_point = '';
}
And of course do a check for the language, otherwise this would be valid for all languages:

Code: Select all

if( $this->config->get( 'config_language' ) == 'bg' ) { ... }

Re: Incorrect number formatting for Bulgarian

Posted: Sun May 17, 2015 8:07 pm
by cheeseus
Great, thank you!

This was fairly easy to implement. Just added, as per your instructions, the following code:

Code: Select all

if ($this->config->get('config_language') == 'bg') {
	if ($value < 9999) {
		$thousand_point = '';
	} 
}
and the numbers now show correctly.