Archive: LTR license in RTL language


LTR license in RTL language
  hey all,

I'm back with yet another language issue.

I'm trying to get the license text in the richedit to show up just like it would for an LTR language. I understand NSIS is manually mirroring the dialog.

The first step I took is to remove the following styles that NSIS is adding to the richedit control:

WS_EX_RTLREADING, WS_EX_LEFTSCROLLBAR and ES_RIGHT

Now the control has the exact same styles as it does when compiled with an LTR language, but the text is still aligning to the right.

Even though the license file is a plain ascii text file (english), I even tried a Unicode version and added a Left-To-Right mark character at the beginning of the file to force LTR alignment, but still no luck.

Even removing WS_EX_RTLREADING adn WS_EX_RIGHT from the parent inner dialog holding the richedit does not change the alignment.

Does anyone have any idea on what needs to be done force the richedit to LTR? Its not one of the window styles as far as I can see....


Thanks


Removing all the styles worked fine for me. I used Resource Hacker to edit dialog 102 and it worked fine. How exactly did you remove the styles?


I'm removing them at runtime with SetWindowLong (verifying removal with spy++).

Can you tell me exactly what you removed? Styles of the richedit or the dialog?

Its my understanding that the default license dialog (102) is configured for LTR viewing, but NSIS manually mirrors it at runtime and applies the RTLREADING styles when an RTL language like Hebrew is selected. I will take another look at dialog 102.


Here is a minimal script that reproduces the issue:

!include "MUI.nsh"

>OutFile "MultiLanguage.exe"
>LicenseData "${NSISDIR}\license.txt"

>page license
>!insertmacro MUI_LANGUAGE "Hebrew"

>Section
SectionEnd
>
here is the resource script for dialog 102


102 DIALOGEX 0, 0, 300, 140

STYLE DS_FIXEDSYS| DS_CONTROL | WS_CHILD | WS_CAPTION
CAPTION ""
>LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
FONT 8
, "MS Shell Dlg"
>{
CONTROL "", 1040, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE, 0, 0, 300, 15
CONTROL"", 1000, "RichEdit20A", ES_LEFT | ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP, 0, 15, 300, 93
CONTROL"", 1006, STATIC, SS_LEFT | WS_CHILD | WS_VISIBLE, 0, 113, 300, 26
>}
I've also attached a screenshot of the issue, can you tell me what you modified to the license text to align to the left, just like when the English language is selected?

Thanks

NSIS doesn't mirror dialogs on runtime. It creates them at build time. Some styles don't take affect immediately after SetWindowLong or at all after the control is created. So you'll have to edit the resources using Resource Hacker after building the installer.

You can also create your own UI based on Contrib\UIs\modern.exe and add the styles you don't want it to have. The dialog manager xors styles it wants to add to make a dialog RTL. So if you add the styles, it'll actually remove it while trying to add it.


Thanks for the info, I'll give the custom UI a try.

Originally posted by kichik
Removing all the styles worked fine for me. I used Resource Hacker to edit dialog 102 and it worked fine. How exactly did you remove the styles?
Can you tell me what you did? Which styles did you add/remove?

I removed the styles you mentioned in your first post. Everything related to RIGHT and all of the extended styles which are all related to RTL anyway.


Thanks for the info, the problem is fixed for the most part.

I've noticed that if multiple languages are included, the installer will include multiple mirrored versions of dialogs (eg dialogs 202, 302 mirrored for 102).

Why are there multiple versions and how to tell which version belongs to which language? for example, I only want to replace the license dialog for Hebrew, how can we know which resource to replace?

Thanks


It adds a dialog set for each different setting it needs to apply. If a specific language has a different font or it's RTL, it'll add a new dialog set for it. Those can't be easily done in runtime so they're prepared in compile-time.

There's no defined set of rules for the order of the dialogs. Currently, it depends on the order in which you've inserted the languages. So long as you don't add new languages, change fonts or RTL and the relevant source code in makensis.exe doesn't change, it's safe to assume the number will stay the same. DOn't forget to make sure it does when one of those change.


Looks I'll have to come up with a way to track the languages added and work out the dialog ids for RTL languages (no font settings in the script) and make needed changes with packhdr to avoid any CRC issues.

Its becoming slightly complex for a simple thing like an LTR license in an RTL page, seemingly because ES_LEFT and WS_EX_LTRREADING dont have any effect once the RichEdit is created with the ES_RIGHT and WS_EX_RTLREADING styles.

Thanks again for all the details, at least the problem is solved.