Hello,
We have a lot of tools and programs written in PureBasic. Currently we are using a CSV style language file (created with OpenOffice Macro) to load from memory during startup. We are loading the sentences into an array depending on system language.
Now, customers asking us to translate to Arabic or Hebrew etc. But these languages are written from right to left. Any suggestions about making our tools able to support right to left? No Windows-API, because it needs to be cross plattform. It this possible with pure PureBasic?
Any hints? Already done such project? Tips?
Kukulkan
How to support right to left written languages?
Re: How to support right to left written languages?
Sorry for bumping it up, but is there really noone who did "right to left" languages in his PB software?
I have problems with mirroring the layout of the programs and PB does not support some RightToLeft constant etc.
Can anyone give me advice?
Kukulkan
I have problems with mirroring the layout of the programs and PB does not support some RightToLeft constant etc.
Can anyone give me advice?
Kukulkan
Re: How to support right to left written languages?
AFAIK, the regional settings have to be changed to use that type of language and PB will support it.
Re: How to support right to left written languages?
Thanks for your reply, but the GUI needs to be mirrored, too. Is Windows doing this or do I need to mirror all gadgets?
I know that, in order to support the language, Windows must be configured to support it. But what do I need to do?
Kukulkan
I know that, in order to support the language, Windows must be configured to support it. But what do I need to do?
Kukulkan
Re: How to support right to left written languages?
I'm guessing that you'd have to mirror the gui
there is no sig, only zuul (and the following disclaimer)
WARNING: may be talking out of his hat
WARNING: may be talking out of his hat
Re: How to support right to left written languages?
Hi Kukulkan
It is not an easy subject and it is not PB fault
Each PB gadget maybe consist of more than one object so it needs some difficult procedure to get your aim
I will add two different exam. hoping to get you start
# 1 :
# 2 :
Good luck
It is not an easy subject and it is not PB fault
Each PB gadget maybe consist of more than one object so it needs some difficult procedure to get your aim
I will add two different exam. hoping to get you start
# 1 :
Code: Select all
UsePNGImageDecoder()
LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/world.png")
If OpenWindow(0, 0, 0, 270, 180, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ComboBoxGadget(0, 10, 10, 250, 21,#PB_ComboBox_Editable)
SetWindowLong_(GadgetID(0),#GWL_EXSTYLE,#WS_EX_LAYOUTRTL)
;chwnd = ChildWindowFromPoint_(GadgetID(0), 4 << 32 + 4)
chwnd = GetWindow_(GadgetID(0),#GW_CHILD)
SetWindowLong_(chwnd,#GWL_EXSTYLE,#WS_EX_LAYOUTRTL)
AddGadgetItem(0, -1, "CB Item 1")
AddGadgetItem(0, -1, "CB Item 2")
lstwnd = FindWindow_("ComboLBox",0)
SetWindowLong_(lstwnd,#GWL_EXSTYLE,#WS_EX_LAYOUTRTL)
ComboBoxGadget(1, 10, 40, 250, 21,#PB_ComboBox_Image)
SetWindowLong_(GadgetID(1),#GWL_EXSTYLE,#WS_EX_LAYOUTRTL)
chwnd1 = ChildWindowFromPoint_(GadgetID(1),4 << 32 + 4)
SetWindowLong_(chwnd1,#GWL_EXSTYLE,#WS_EX_LAYOUTRTL)
AddGadgetItem(1, -1, "CB Item 1",ImageID(0))
lstwnd1 = FindWindow_("ComboLBox",0)
SetWindowLong_(lstwnd1,#GWL_EXSTYLE,#WS_EX_LAYOUTRTL)
ComboBoxGadget(2, 10, 70, 250, 21)
SetWindowLong_(GadgetID(2),#GWL_EXSTYLE,#WS_EX_LAYOUTRTL)
For a = 1 To 5
AddGadgetItem(2, -1,"ComboBox item " + Str(a))
Next
lstwnd2 = FindWindow_("ComboLBox",0)
SetWindowLong_(lstwnd2,#GWL_EXSTYLE,#WS_EX_LAYOUTRTL)
keybd_event_(#VK_MENU,0,0,0)
keybd_event_(#VK_RSHIFT,0,0,0)
keybd_event_(#VK_RSHIFT,0,#KEYEVENTF_KEYUP,0)
keybd_event_(#VK_MENU,0,#KEYEVENTF_KEYUP,0)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case 0
LangFlag = LangFlag !1
If LangFlag = 0
keybd_event_(#VK_RCONTROL,0,#KEYEVENTF_EXTENDEDKEY,0)
keybd_event_(#VK_RSHIFT,0,#KEYEVENTF_EXTENDEDKEY,0)
keybd_event_(#VK_RSHIFT,0,#KEYEVENTF_KEYUP|#KEYEVENTF_EXTENDEDKEY,0)
keybd_event_(#VK_RCONTROL,0,#KEYEVENTF_KEYUP|#KEYEVENTF_EXTENDEDKEY,0)
Else
keybd_event_(#VK_LCONTROL,0,0,0)
keybd_event_(#VK_LSHIFT,0,#KEYEVENTF_EXTENDEDKEY,0)
keybd_event_(#VK_LSHIFT,0,#KEYEVENTF_KEYUP,0)
keybd_event_(#VK_LCONTROL,0,#KEYEVENTF_KEYUP,0)
EndIf
EndSelect
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
# 2 :
Code: Select all
#CDDS_ITEMPREPAINT = #CDDS_ITEM|#CDDS_PREPAINT
#CDDS_SUBITEMPREPAINT = #CDDS_SUBITEM|#CDDS_ITEMPREPAINT
#MB_RIGHT = $80000
#MB_RTLREADING = $100000
Global ListGadget,EditGadget,LangFlag,WinFlag,Color_1,Color_2,FontReg,FontBold,Fontname$
Color_1 = RGB(255, 255, 224)
Color_2 = RGB(255, 240, 177)
Fontname$ = "Microsoft Sans Serif"
FontReg = LoadFont(1, Fontname$, 12)
FontBold = LoadFont(2, Fontname$, 12, #PB_Font_Bold)
ArKH = LoadKeyboardLayout_("00000401",#KLF_REORDER)
EnKH = LoadKeyboardLayout_("00000409",#KLF_REORDER)
Procedure AlignColumn(liGad, col, align)
liColumn.LV_COLUMN
liColumn\mask = #LVCF_FMT
liColumn\fmt = align
SendMessage_(liGad, #LVM_SETCOLUMN, col, liColumn)
EndProcedure
Procedure WndProc(hwnd, uMsg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_NOTIFY
*pnmh.NMHDR = lParam
Select *pnmh\code
Case #NM_CUSTOMDRAW
*LVCDHeader.NMLVCUSTOMDRAW = lParam
If *LVCDHeader\nmcd\hdr\hWndFrom=ListGadget
Select *LVCDHeader\nmcd\dwDrawStage
; Case #CDDS_PREPAINT
; result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
result = #CDRF_NOTIFYSUBITEMDRAW
Case #CDDS_SUBITEMPREPAINT
Row = *LVCDHeader\nmcd\dwItemSpec
Col = *LVCDHeader\iSubItem
If Col=0
SelectObject_(*LVCDHeader\nmcd\hDC, FontBold)
Else
SelectObject_(*LVCDHeader\nmcd\hDC, FontReg)
EndIf
If Row&1=1
*LVCDHeader\clrTextBk = Color_2
; If Col <> 0
; *LVCDHeader\clrText = RGB(0, 0, 0)
; Else
; *LVCDHeader\clrText = RGB(255, 0, 0)
; EndIf
; Else
; *LVCDHeader\clrTextBk = RGB(255, 255, 223)
; If Col <> 0
; *LVCDHeader\clrText = RGB(0, 0, 0)
; Else
; *LVCDHeader\clrText = RGB(255, 0, 0)
; EndIf
EndIf
result = #CDRF_NEWFONT
EndSelect
EndIf
EndSelect
Case #WM_GETMINMAXINFO
*pMinMax.MINMAXINFO = lParam
*pMinMax\ptMinTrackSize\x=808
*pMinMax\ptMinTrackSize\y=634
Case #WM_SIZE
WinX = WindowWidth(0)
WinY = WindowHeight(0)
MoveWindow_(GadgetID(1),10,WinY*6/10+20,WinX-20,WinY*3/10,1)
MoveWindow_(GadgetID(2),10,WinY-30,100,25,1)
MoveWindow_(GadgetID(3),10,10,WinX-20,WinY*6/10,1)
EndSelect
ProcedureReturn result
EndProcedure
WinX = 800
WinY = 600
hWnd = OpenWindow(0,0,0,800,600," RASHAD Database Control ",#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
SetWindowCallback(@WndProc(),0)
EditorGadget(1,10,380,780,170)
ButtonGadget(2, 10,560, 100, 25, "Change Language")
ListGadget = ListIconGadget(3,10,10,780,360,"#######",80,#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines|#WS_BORDER)
SetGadgetColor(3,#PB_Gadget_LineColor,$C3C3C3)
header = SendMessage_(ListGadget, #LVM_GETHEADER, 0, 0)
AlignColumn(ListGadget, 0,#LVCFMT_CENTER)
SetGadgetColor(3, #PB_Gadget_BackColor, Color_1)
SetGadgetFont(3, FontID(1))
AddGadgetColumn(3,1,"Column 1",200)
AddGadgetColumn(3,2,"Column 2",200)
AddGadgetColumn(3,3,"Column 3",200)
AddGadgetColumn(3,4,"Column 4",200)
AddGadgetColumn(3,5,"Column 5",200)
AddGadgetColumn(3,6,"Column 6",200)
AddGadgetColumn(3,7,"Column 7",200)
For i=0 To 100
AddGadgetItem(3, -1, "Line "+Str(i)+Chr(10)+"Line "+Str(i)+" col 1"+Chr(10)+"Line "+Str(i)+" col 2"+Chr(10)+"Line "+Str(i)+" col 3"+Chr(10)+"Line "+Str(i)+" col 4"+Chr(10)+"Line "+Str(i)+" col 5"+Chr(10)+"Line "+Str(i)+" col 6"+Chr(10)+"Line "+Str(i)+" col 7")
Next
WinFlag = #WS_EX_LAYOUTRTL | 0
ActivateKeyboardLayout_(ArKH,#KLF_REORDER)
SetWindowLongPtr_(ListGadget,#GWL_EXSTYLE,WinFlag)
SetWindowLongPtr_(header,#GWL_EXSTYLE,WinFlag)
SendMessage_(ListGadget, #LVM_SCROLL, 0, 1)
MessageBox_(0,"عربي","RTL Text",#MB_RIGHT|#MB_RTLREADING|#MB_OK)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case 2
If LangFlag = 0
LangFlag = 1
ElseIf LangFlag = 1
LangFlag = 0
EndIf
If LangFlag = 0
WinFlag = #WS_EX_LAYOUTRTL | 0
ActivateKeyboardLayout_(ArKH,#KLF_REORDER)
Else
WinFlag = 0
ActivateKeyboardLayout_(EnKH,#KLF_REORDER)
EndIf
SetWindowLongPtr_(ListGadget,#GWL_EXSTYLE,WinFlag)
SetWindowLongPtr_(header,#GWL_EXSTYLE,WinFlag)
SendMessage_(ListGadget, #LVM_SCROLL, 0, 1)
If LangFlag = 0
MessageBox_(0,"عربي","RTL Text",#MB_RIGHT|#MB_RTLREADING|#MB_OK)
Else
MessageBox_(0,"English","LTR Text",#MB_OK )
EndIf
EndSelect
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
End
Egypt my love
Re: How to support right to left written languages?
Maybe there is a way to set it once and let Windows do more or less the rest: http://msdn.microsoft.com/en-us/library ... _mirroring
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: How to support right to left written languages?
Hi c4s
Switching window and switching gadget not enough to do the job
Believe me
Switching window and switching gadget not enough to do the job
Believe me
Code: Select all
#MB_RIGHT = $80000
#MB_RTLREADING = $100000
Procedure RTLwindow(WinNum.l,Switch.l)
If Switch = 1
SetWindowLongPtr_(WindowID(WinNum),#GWL_EXSTYLE, #WS_EX_LAYOUTRTL | 0)
ElseIf Switch = 0
SetWindowLongPtr_(WindowID(WinNum),#GWL_EXSTYLE,0)
EndIf
; Window Refresh Is Required
SetWindowPos_(WindowID(WinNum), 0, -1 , -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE | #SWP_NOZORDER | #SWP_FRAMECHANGED | #SWP_SHOWWINDOW)
EndProcedure
Procedure RTLgadget(GadgetNum.l,Switch.l)
If Switch = 1
SetWindowLongPtr_(GadgetID(GadgetNum),#GWL_EXSTYLE, #WS_EX_LAYOUTRTL | 0)
ElseIf Switch = 0
SetWindowLongPtr_(GadgetID(GadgetNum),#GWL_EXSTYLE,0)
EndIf
EndProcedure
Egypt my love
Re: How to support right to left written languages?
Thanks all,
I will try the code examples. I already use some layer around the PB Gadgets (different reasons) and maybe I simply can add it there.
Thanks,
Kukulkan
I will try the code examples. I already use some layer around the PB Gadgets (different reasons) and maybe I simply can add it there.
Thanks,
Kukulkan


