Aspose fails to initialise with some locales

Hi there,

We’re having troubles where Aspose fails to initialise, depending on the locale data that we initialise with.

For example, the following example in Java:

License slidesLicence = new License();
slidesLicence.setLicense(new ByteArrayInputStream(LICENCE_DATA.getBytes(StandardCharsets.UTF_8)));
Locale.setDefault(new Locale("en", "KR"));
String[] fontDirs = {};
FontsLoader.loadExternalFonts(fontDirs);

throws this exception

Culture Name: en-KR is not a supported culture

We’re seeing this in the following products:

  • aspose_email: [‘com.aspose:aspose-email:18.3:jdk16’],
  • aspose_pdf: [‘com.aspose:aspose-pdf:18.3’],
  • aspose_slides: [‘com.aspose:aspose-slides:18.2:jdk16’],
  • aspose_words: [‘com.aspose:aspose-words:18.3:jdk16’],

There’s a similar thread that mentions this was fixed, but it doesn’t appear to be the case, based on our testing: Culture Name: en-RS is not a supported culture (MAC Java) (1496)

@nuix,

I have observed your requirements and like to share that Aspose APIs support standard locales supported by Java platforms. Therefore, by design java.lang.IllegalArgumentException: Culture Name: xx-XX is not a supported culture is used for the wrong Locale. I hope the shared information will be helpful.

Hmm, I see.

The problem with this is that generally in Java applications, when an unrecognised locale is encountered, the standard behaviour is to fallback to the parts of the locale that are recognised. This behaviour is described in Around the World in Java: Misconceptions about Java Internationalization

Whereas Aspose has no fallback behaviour, so instead it just comes to a halt and throws that exception. We consider this a bug.

This is causing an issue for our users who have their operating system settings in a “non-standard” combination, for example – language: English, country: Korea. The only part of our application that is having trouble with this combination is Aspose.

In order to work around this limitation in Aspose, we’re looking at forcing the locale of Aspose to “en-US” when this initialisation error occurs.

Unfortunately, we’re having trouble finding the appropriate methods to set the locale for each Aspose library. Could you help with that?

Locale.setLocale is impractical for us because we’re in a multithreaded environment. Also, because we only want to override Aspose’s processing language, not the language used in our user interface.

For aspose.words we can see CurrentThreadSettings.setLocale, which is great for this workaround, as we can restrict the changes to a single thread. It’s great.

For aspose.cells, we can see LoadOptions.setLocale, which seems to be suitable for this workaround as well.

However! For the following APIs, I couldn’t find a setLocale method at all:

  • aspose.cad
  • aspose.diagram
  • aspose.email
  • aspose.imaging
  • aspose.pdf
  • aspose.slides
  • aspose.note

Do these libraries have locale-setting functionality in the API, and if so, could you please let me know which methods we can use?

Thanks!

@nuix,

Thank you for sharing the feedback. We have created following enhancement tickets in our issue tracking system to further investigate the possibility of providing requested support in other APIs as well.

  • For Aspose.PDF PDFJAVA-37857 has been created.
  • For Aspose.Diagram DIAGRAMJAVA-50611 has been created.
  • For Aspose.Slides SLIDESJAVA-37157 has been created.
  • For Aspose.Imaging IMAGINGJAVA-1043 has been created.
  • For Aspose.CAD CADJAVA-352 has been created.
  • For Aspose.Notes NOTEJAVA-465 has been created.
  • For Aspose.Email EMAILJAVA-34394 has been created.

We will share feedback with you as soon as the associated issues will be addressed.

The issues you have found earlier (filed as DIAGRAMJAVA-50611) have been fixed in this update. This message was posted using BugNotificationTool from <a href=“https://#{request.env[“HTTPS_HOST”]}”>Downloads module by Farhan.Raza

Hi Mudassir,

Just to clarify – which fix will be implemented in these enhancement tickets?

Thanks!

@nuix,

I have observed your comments and like to share that at present the concerned implementation has not been done in any of associated API. However, we have updated the information shared by you in concerned Jira tickets and will share the feedback with you as soon as the issues will be fixed.

The issues you have found earlier (filed as PDFJAVA-37857) have been fixed in Aspose.PDF for Java 18.8.

The issues you have found earlier (filed as IMAGINGJAVA-1043) have been fixed in this update.

The issues you have found earlier (filed as ) have been fixed in this update.

The issues you have found earlier (filed as SLIDESJAVA-37157) have been fixed in this update.

The issues you have found earlier (filed as NOTEJAVA-465) have been fixed in Aspose.Note for Java 19.4. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi