We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Locale pr. thread

Hi

We have documents that we generate for multi languages, when the document has mergefields with formatting like @ \"MM yyyy, we need to be able to control the locale being used pr. thread.
In Java there is not option of setting the locale pr. thread, so Aspose uses the default locale.
We cannot change this the default locale (its pr. vm instance), so is it possible to add a method on Document? - something like:

doc.setCurrentLocale(new Locale("da," "DK"));

Regards
Morten

Hi Morten,

Thanks for your inquiry. Aspose.Words supports multilingual documents. You can manipulate such document or create them from scratch. It would be great if you please share following detail for investigation purposes.


  • Please attach your input Word document.
  • Please

    create a standalone/runnable simple application (for example a Console
    Application Project
    ) that demonstrates the code you used to generate
    your output document

  • Please attach the output Word file that shows the undesired behavior.
  • Please
    attach your target Word document showing the desired behavior. You can
    use Microsoft Word to create your target Word document. I will
    investigate as to how you are expecting your final document be generated
    like.

Unfortunately,
it is difficult to say what the problem is without the Document(s) and
simplified application. We need your Document(s) and simple project to
reproduce the problem. As soon as you get these pieces of information to
us we’ll start our investigation into your issue.

Last I wrote, I gave up to reply to your answer, as it seems as if the question had not been read at all. At that time I found a workaround, but now I ran into the problem again.


Could I bother you to please try to read my question again and not come up with the standard answer? (example, example, example)

Regards

Hi Morten,

Please accept my apologies for your inconvenience.


Locale.setDefault sets the default locale for the specified Category for this instance of the Java Virtual Machine. Please set the Locale where you are executing the Aspose.Words code. See the following code snippet.

Locale.setDefault(new Locale(“fr”, “FR”));

Document doc = new Document(MyDir + “in.docx”);


If you face any issue, please share the culture detail, input and output documents for testing. We will investigate the issue on our side and provide you more information.


Hi


As I wrote, a call to Locale.setDefault(…) will set the default locale for this instance of the Java Virtual Machine - this is bad - this is what the documentation says:

Since changing the default locale may affect many different areas of functionality, this method should only be used if the caller is prepared to reinitialize locale-sensitive code running within the same Java Virtual Machine.

We want each letter to be printet after a Locale that we determine based on the preferred language from the receiver of the print. We have a print job printing in many treads, these can not individually set the default locale, as it will affect each other… (again, please dont request a example)

RegardMorten

Hi Morten,

Thanks for your inquiry. We have logged a feature request as WORDSNET-12961 in our issue tracking system to set the Locale for a Document. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

wotnot:
We want each letter to be printet after a Locale that we determine based on the preferred language from the receiver of the print.
Could you please share how you determine the Locale for a Document?

Hi


Our documents are stored in a database in a table with blob field. In the same table we have a registration of the language (locale) it is written in.

Regards
Morten

Hi Morten,

Thanks for your feedback. We will update you via this forum thread once this feature is available. Please let us know if you have any more queries.


Hi Morten,

Thanks for your patience. These are Java specific issues. Please use the new CurrentThreadSettings class to set ThreadLocal or/and ThreadLocal before open/save a document with non-default locale settings. Hope, this helps.