Use a different locale per thread

  • In a project I use WPTools in a server-environment to perform mail merging. It may happen that 2 clients will perform a merge at the same time, and that both clients use a different language.

    One of the problems is merging the date field (for weeknames and monthnames such as January, February etc.).

    Is it possible to assign weeknames and monthnames per thread, so 2 threads can merge simultaneously in different languages?

    • Offizieller Beitrag

    I don't know if you can replace the global locale per thread but you can easily use the OnTextObjGetTextEx event to create whatever information is required for the DATE or TIME fields.

    This example gets the TFormatSettings for a certain locale and uses it to create a date string:

  • Zitat von wpsupport

    I don't know if you can replace the global locale per thread but you can easily use the OnTextObjGetTextEx event to create whatever information is required for the DATE or TIME fields.

    This example gets the TFormatSettings for a certain locale and uses it to create a date string:

    I tried to use the OnTextObjGetTextEx event, but the event never gets fired. Do I need to do something to enable the event?

  • Zitat von wpsupport

    Hi,

    this event should fire for this text objects field. I tested it through. Please try the bookmarks demo, it uses it, too.

    Julian

    In the bookmarks demo the event fires. However, in my code the event does not fire. May I need to do certain things?

    A piece of the relevant code I use:

  • Zitat von wpsupport

    Please add
    TXTObject.Params := PrintString;

    at the end of DoTextObjGetTextEx(). This will set the string which is written into the result \fldrslt of the text field.

    Julian

    That did the trick, thanks!