Bug 116678 - [FORMATTING,FILESAVE,FILEOPEN] TEXT function format code argument is not properly translated in locale change
Summary: [FORMATTING,FILESAVE,FILEOPEN] TEXT function format code argument is not prop...
Status: CLOSED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86-64 (AMD64) Linux (All)
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-28 09:41 UTC by Gérard Dethier
Modified: 2018-04-13 10:58 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Example XLS file with formatting working when locale is fr-BE but not when locale is changed to en-US (5.50 KB, application/vnd.ms-excel)
2018-03-28 09:44 UTC, Gérard Dethier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gérard Dethier 2018-03-28 09:41:14 UTC
Description:
In LibreOffice Calc 5.4.5.1 with locale fr-BE, when editing an XLS file, the formula for formatting a date in a cell with TEXT function must be written TEXTE(DATE(2018;3;28);"aaaamm") when function name translation is not disabled (which is the default). The equivalent English formula is TEXT(DATE(2018,3,28),"yyyymm").

However, when saving this to a file and reading it with Apache POI library (https://poi.apache.org/), the persisted formula is TEXT(DATE(2018,3,28),"aaaamm") which is OK except for the format string that has not been translated into "yyyymm".

Using directly the English format code ("yyyymm") prevents the date to be properly formatted in LibreOffice but leads to the persistence of the right formula in the file.

I would expect that:

1. TEXTE(DATE(2018;3;28);"aaaamm") (or whatever internationalized equivalent) is properly persisted as TEXT(DATE(2018;3;28);"yyyymm")
2. Disabling function name translation also disables format code translation (i.e. "yyyymm" becomes a valid format code)

Note that a possible workaround is to change the locale of LibreOffice to English via Menu > Options > Language Settings.

Steps to Reproduce:
1. In LibreOffice Calc 5.4.5.1 with fr-BE locale, format a date using TEXT function e.g. TEXTE(DATE(2018;3;28);"aaaamm") or TEXT(DATE(2018;3;28);"aaaamm") without function name translation.
2. Save the file
3. Change LibreOffice locale to en-US
4. Open the file and see that formatting does not work as expected

Actual Results:  
Cell contains text Wednesday01

Expected Results:
Cell should contain text 201803


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 5.4.5.1
Build ID: 1:5.4.5-0ubuntu0.17.10.5
Threads CPU : 4; OS : Linux 4.13; UI Render : par défaut; VCL : gtk3; 
Locale : en-US (fr_BE.UTF-8); Calc: group


User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0
Comment 1 Gérard Dethier 2018-03-28 09:44:36 UTC
Created attachment 140933 [details]
Example XLS file with formatting working when locale is fr-BE but not when locale is changed to en-US
Comment 2 Buovjaga 2018-04-10 18:57:00 UTC
Reproduced.

Arch Linux 64-bit
Version: 6.1.0.0.alpha0+
Build ID: d4c0e7ef2b7f7e3cb36996bad72ac255b630beb4
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on April 8th 2018

Arch Linux 64-bit
LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 3 Eike Rathke 2018-04-13 10:58:43 UTC
The format code argument is user supplied text *data*, which we can't "translate". It can even be constructed with a formula expression. With LibreOffice 6.0 English format code keywords can be used in all locales (see https://wiki.documentfoundation.org/ReleaseNotes/6.0#Calc), though that IMHO still may not work in Excel for all locales. There's nothing more we can do.