Getting rid of the decimal comma in Ubuntu

At some point in school, we South Africans are told that the official decimal separator is the comma.1 Most of us then proceed to ignore this—at least in English use2—because it differs from the decimal point used in the rest of the English-speaking world, and thereby creates confusion. Thankfully, the maintainers of the glibc locale data—and thus the number formats used in Linux systems—agree with me on this question, and the South African English locale uses the decimal point.

Unfortunately, the developers of Ubuntu Linux have come across a government communications style guide—a style guide widely ignored even within the governmentwhich specifies the use of the decimal comma. They have therefore included in Ubuntu a patch which changes the decimal separator for South African English to a comma.3 Reversing this change is one of the first things I do after setting up a new Ubuntu (or Linux Mint) install. Fortunately it is quite easy, and I give the instructions here to help those who suffer from the same annoyance.

The simple way

Run the command

sudo update-locale LC_NUMERIC="en_GB.UTF-8"

The change won't take effect until you log out and back in again. This tells your system to use the British English settings for number formatting, and therefore to use the decimal point.

(If, for some reason, update-locale doesn't work for you, you can produce the same results by adding the line LC_NUMERIC="en_GB.UTF-8" to the file /etc/default/locale.)

The problem

This method changes LC_NUMERIC which defines the format for ordinary numbers, but not LC_MONETARY, which defines the format for currency values. We could change LC_MONETARY to "en_GB.UTF-8", but then it would also change the currency symbol from "R" to "£".

The complicated way

If we want to change the decimal separator for monetary values, without changing the currency symbol, we will have to edit the en_ZA locale definitions. You can download my patch file en_ZA-decimal-point.patch, and then apply it to the locale definitions by running the commands

sudo patch /usr/share/i18n/locales/en_ZA en_ZA-decimal-point.patch
sudo locale-gen

The changes will take effect immediately. You may have to repeat this process if the locales package is upgraded, because the upgrade will overwrite the locale definitions.


  1. Per the "National Measuring Standards", Government Notice R. 1144, published on 5 July 1974 in Government Gazette No. 4326.
  2. I am informed that in Afrikaans the decimal comma is more commonly used. I have no information about the other South African languages.
  3. See Launchpad bug #887395 and ubuntu-en_ZA-decimal.patch.

Western Cape number plate codes

Ever wondered where that (Western Cape registered) car is from? Wonder no more: (you can click on the map to see a bigger version)

Map of Western Cape number plate prefixes

(Based on this Wikipedia article.)

Tags:

Change in parties' share of the vote, 2009 to 2014

I've drawn some maps showing the percentage-point change between the 2009 and 2014 elections in the vote share of the major parties (or, in the case of COPE, formerly major parties). Because municipal boundaries have changed a bit, I had to recalculate the 2009 results for the 2014 boundaries, by assigning the voting districts from 2009 to wards from 2014. In the cases where a 2009 VD was spread across multiple 2014 municipalities, I assigned it according to the location of the voting station.

As always, click on the map to see the full-size version.

African National Congress (ANC)

The ANC has increased its share substantially in some parts of the Western and Northern Cape; but it appears to have been at the cost of COPE or other smaller opposition parties, as the DA has also seen an increase in most of these areas (see the next map).

Democratic Alliance (DA)

Some of the substantial increases seen by the DA are thanks to its absorption of the Independent Democrats.

Economic Freedom Fighters (EFF)

Since the EFF is a new party the map just shows its share of the vote in 2014. The municipality where it won more than 20% is, unsurprisingly, Rustenburg, where it won 20.22% of the vote.

Congress of the People (COPE)

Essentially, this map just shows COPE's share of the vote in 2009. In the places where it won more votes in 2009, it had more votes to lose in 2014.

Inkatha Freedom Party (IFP)

The IFP lost badly in northern KZN, shedding votes to the breakaway NFP and, to a lesser extent, the ANC.

National Freedom Party (NFP)

The NFP, which broke away from the IFP before the 2011 municipal elections, managed to win a substantial share of the vote in northern KZN.

Tags:

2014 election results map

The detailed 2014 election results map promised in my last post is live! It has all the features of the 2009 map, plus you can see the results from both the national and the provincial ballots. As before, you can zoom right down to street level and see the results for individual voting districts.

By way of example, here you can see it with the provincial ballot results from my voting station.

The code, incidentally, is available on GitHub. The PostGIS database that backs it up can be downloaded here, but be warned it is 700MB. Available for separate download are:

Another new election results site

As a long-weekend project I've put together this interactive map of the 2009 South African election results. It's a "slippy" (i.e. scrollable and zoomable) map and you can zoom right down to street level and see the results for individual voting districts. (Something you can't do with the News24 election map!)

Use the buttons in the top left to choose the level of detail—province, district municipality, local municipality, ward or voting district—though wards and voting districts aren't available until you zoom in a few levels. Click on an area on the map to see the results for that area. For example, here are the results from my voting district in Rosebank.

It's my plan to have a version with the 2014 election results up as soon as possible after the IEC releases the detailed results spreadsheets once the election is declared.

New site - visualizing election results

I have a new site up which graphically displays information about the results of the 2009 South African elections. This project was an exercise in learning to use the D3.js framework. All the code and data is available in a github repository.

Map of electrification from 1996 to 2011

New map I drew this weekend: it shows the spread of electrification in South Africa from 1996 to 2011, based on census data. The actual variable measured is "Main source of energy for lighting". As usual, click for the full-size version.

Home language distribution map

I have added a layer showing the distribution of first/home languages from Census 2011 to my dot distribution map website. Next up: household income.

Zoomable, scrollable racial dot distribution map of South Africa

Following on from the maps described in my previous blog posts, I've now create a zoomable, scrollable dot map showing racial distribution across the whole of South Africa

Comparing 2001 and 2011

For comparison with the 2011 census maps in my previous blog post, I've drawn similar maps based on the 2001 census data. There are two caveats to this: firstly, the 2001 census only made the race data available at a subplace (i.e. suburb) level, although the density is accurate to similar levels as the 2011 maps. Secondly, the 2001 census did not include the response of "Other" to the race question.

Here's Cape Town (2001 first and 2011 second; as before, click for full-size):

 

 

Joburg:

 

Durban:

 

My next long-term project is to turn this type of data into an overlay for Google Maps/OpenStreetMap so that you can scroll around and see how this looks across the whole country.

Pages

Subscribe to