Hi,
is there a dependency with the locale setting and evaluating word field functions?
One of our documents (created on a system with de-DE setting) includes a field function like this:
{ IF "{= AND({COMPARE "1"="1"} ; {COMPARE "0"="0"})} ="1" "true" "false" }
At call of doc.updateFields(), depending on the locale setting of the system our application is running on, the field function is properly evaluated, i.e. for locale setting “de_DE.utf8” the function correctly evaluates to “true” but for locale setting “en-EN.utf8” it evaluates incorrectly to “false”.
When replacing the field function with a if-then-else construct, instead of using “compare,” it is properly evaluated regardless of the locale setting.
We’ve also experimented with setting different charsets via the LoadOptions, when creating the aspose document, but this didn’t make a difference. Only after setting our (docker) environment to de-DE (which is fine for now), the functions are properly evaluated.
Thanks!
@support.enowa.ag
Could you please provide more details about the environment in which you are running the application, such as the version of Aspose.Words you are using and any specific configurations related to locale settings?
Issue is with aspose.word versions 23.3 and 25.2
Apllication is a JEE application (jdk17) running on quarkus.
Running the applciation on a quarkus test environment locally on a Windows System (with german settings) the function is properly evaluated.
In production, the application is running in docker with a red-hat linux base image (initially with en-EN locale). Only after setting the linux image to german, functions have been evaluated properly also in this environment.
So far, we’ve seen this also only with the Word “compare” function (but there might be other functions as well, that could potentially be affected?)
@support.enowa.ag
Yes, depending on the locale different separators between function arguments must be used. In de_DE
locale comma is used as a decimal separator, so it cannot be used as a separator in AND
function. On other hand in en-EN
dot is a decimal separator, so comma is used as a separator in AND
function.
According to the documentation.
Arguments must be separated by the list separator defined in the regional settings in Microsoft Windows Control Panel, either a comma (,) or semicolon (;).
1 Like
Thanks for clarification.
Is there actually a way in Aspose to set the Locale or the separators to use (e.g. via LoadOptions), instead of relying on system settings?
@support.enowa.ag Sure you can use code like this:
// Set locale for the current thread.
Locale current = CurrentThreadSettings.getLocale();
CurrentThreadSettings.setLocale(Locale.GERMAN);
// process your document here
// .......................
// Restore locale.
CurrentThreadSettings.setLocale(current);
1 Like
Shoot! Yes, thanks. Setting the local just within the application… The obvious didn’t came to our mind.
1 Like