South Africa decimal separator

Just another question on the topic,
Is LibreCALC supposed to get its settings from the system locale?
If yes which settings does it get? because if that’s the case it is a bug and if no, well… then it should have a feature to have custom settings

Have a look at this,

import locale

# Set the locale to en_US.UTF-8 (this locale must be installed on your system)
# Windows may use a different string, such as 'English_United States.1252' or just 'us'
try:
    locale.setlocale(locale.LC_ALL, 'en_ZA.utf8')
except locale.Error as e:
    print(f"Could not set locale: {e}. Trying alternative...")
    try:
        # Alternative for Windows or other systems
        locale.setlocale(locale.LC_ALL, 'za')
    except locale.Error as e_alt:
        print(f"Could not set alternative locale: {e_alt}")
        # Fallback to a default or handle the error as appropriate

# Get the currency symbol
conv = locale.localeconv()
currency_symbol = conv['currency_symbol']

print(f"The currency symbol for en_ZA locale is: {currency_symbol}")

# Example of formatting a number
amount = 1999999.99
formatted_amount = locale.currency(amount, grouping=True, symbol=True)
print(f"Formatted amount: {formatted_amount}")

Here’s the output when I run that,
See it looks good to me…

The currency symbol for en_ZA locale is: R
Formatted amount: R1 999 999.99

That’s from the OS, why doesnt libreoffice use the operating system settings ?

It’s part of a report generated by LibreOffice 25.8.
Set the locale to English (South Africa), open a spreadsheet and enter a decimal with dot as decimal separator into A1.
Hit Ctrl+F8 (or menu:View>Highlight Values). The blue font color indicates that the value in A1 is a number, indeed.
Separator for decimals, dates, times and thousands are hard wired for the South African locale. You can’t change them. If you want some other combination, find another locale.
The attachment contains Python code with an installer routine to generate the locale table.
reportNumberFormats.odt (59.2 KB)

This thread seems to be only on the defaults you get, when setting a locale.
.
You can set any (ok most) formattings you like for your personal templates. You can even use more than one template, but obviously there can only be one default template (this you can set according to your needs).

Update to LibreOffice version 24.8, see ReleaseNotes/24.8 - The Document Foundation Wiki

3 Likes