Tuesday, 7 July 2015

E2B 1.72BetaB with support for Arabic, Hebrew, Urdu, etc.

E2B 1.72BetaB+ has added support for RTL languages (but no STRINGS.txt language files yet!)

BetaC fixes Windows sub-menus not being right-justified + few other small niggles.



E2B can support different languages by looking up $$$STR keywords in the STRINGS.txt file. e.g.

$$STRm004=\x20 Windows 引导菜单  

However, some languages, such as Arabic, Persian, Hebrew, etc. read from right-to-left (RTL).

Currently, I have these rules for E2B support of RTL languages:

1. Menu headings, menu entries, menu entry help text in the STRINGS.txt file must be written RTL. When displayed by E2B, these entries will be right-aligned. If CENTREHD is used, menu headings will be centred. The text in STRINGS.txt is not reversed by E2B - it will appear in the same order on the screen. You may need to use Fribidi to help create a STRINGS.txt file (see below).

2. Other text, user info and prompts, etc. in the STRINGS.txt file (console text, e.g. user prompts, etc.) can be written RTL, but when it is displayed by E2B, it will not be right-aligned. You could use spaces to pad out multiple lines so that they are right-aligned - e.g. to see this format

                      xxxxxxxxx
                      ========
     dddddddddddddddddd
 : (N/Y) sd sd sds dsdsdsd

You would need to make a single line like this:

$$STRabcd=                      xxxxxxxxx\n                      ========\n     dddddddddddddddddd\n : (N/Y) sd sd sds dsdsdsd

Not easy!

3. E2B embedded program messages, grub4dos English text\error messages will not be right-aligned (normal LTR English).

4. Enumerated Payload file menu entries will be right-aligned by E2B automatically. The help text under the menu will also be right-aligned automatically.

5. Any menu entry and help text in a user .mnu file will be right-aligned by E2B but not reversed. You must reverse it in the .mnu file if it comes out wrong!.

6. Any menu entry and help text in a user .txt file will be right-aligned by E2B but not reversed. You must reverse in the .txt file. You must reverse it in the .mnu file if it comes out wrong!.


To use a RTL language, you will need to set the LANG and RTL variables in the \_ISO\MyE2B.cfg file. Also turn off the menu autonumbering and get rid of the grub4dos menu pointer on the right-hand side by patching 0x8308 and turn off the border and centre the headings (optional):

Typical settings for a RTL language in MyE2B.cfg:

if "%LANG%"=="" set LANG=ARABIC
set RTL=1
set AUTONUM=0
write 0x8308 0 > nul
#set bdwidth=0
#set CENTREHD=1


If RTL=1 then the menuw menu width value will be used (standard use). RTL can also be set to any width above 10 to override this value - e.g. set RTL=52.


I will describe the menu entries:

Heading - this is the Main Menu heading, as set in the MyE2B.cfg file. It is right-aligned because CENTREHD is not set. The order of the characters is not reversed by E2B.

0 Set default - this comes from the STRINGS.txt file which is still in English. Once STRINGS.txt has been changed, it will appear correctly. The text in the STRINGS.txt file will be displayed in the same order, it is just right-aligned by E2B.

[01]  - this menu entry comes from a .mnu file which is UTF-8 encoded and written from right-to-left, E2B has just right-aligned it.

Footer text - this is set in the MyE2B.cfg file. It is placed in a precise position defined by HBTM. The order of the characters is not reversed by E2B or right-aligned. Hopefully it reads correctly?

The actual words are just random Arabic words, but they should at least be readable (I think???).
Please contact me if you would like to work with me to provide a STRINGS.txt in your own language.
If you would like to provide me with a STRINGS.txt file in your own RTL language (e.g. Urdu, Hebrew, Arabic), please send it to me for testing.



Letters in a .txt file or .mnu or .lst file must be written backwards. you need to use fribidi.exe to reverse the text so that you can use it in a .mnu or .txt or .lst file. 

1- make your own .mnu or .txt or .lst file 

title برنامج نورتون جوست\nبرنامج نورتون جوست 2-

2. Reverse it with Reverse.cmd script "Drag-and-drop" your .mnu file or .txt or .lst file (in UTF-8 encoding) onto it to create a new 'rev' file".

A .txt file or .mnu file would be written as shown below (E2B will only right-justify then menu entry, it will not change the order of the characters): 

title ﺖﺳﻮﺟ ﻥﻮﺗﺭﻮﻧ ﺞﻣﺎﻧﺮﺑ\nﺖﺳﻮﺟ ﻥﻮﺗﺭﻮﻧ ﺞﻣﺎﻧﺮﺑ

3. Rename the new file as required.

Reverse it with Fribidi

If grub4dos is displaying the glyphs backwards, you will need to use fribidi.exe to reverse the  text so that you can use it in a .mnu or .txt file.

In the \_ISO\docs\E2B Utilities\Fribidi folder, there is a Reverse.cmd script.
Drag-and-drop your .mnu file or .txt file (in UTF-8 encoding) onto it to create a new 'rev' file.

e.g. Ubuntu.mnu will be converted to Ubunturev.mnu.

For non-E2B grub4dos

The grub4dos script that right-aligns menus (\_ISO\e2b\grub\rtl.g4b) can be used for normal non-E2B grub4dos menus too. It just requires a few small changes.

I use 'menusetting' to define the size and position of the menu.

e.g. If your menu is a UTF-8 text file called  menu1.lst, then to display it in grub4dos as right-aligned, you would need to use the following grub4dos code instead of just  'configfile /menu1.lst' :

# RTL is the width of the menu
set RTL=60
# copy menu to 'sector' 0x3000 in memory
dd if=()/menu1.lst of=(md)0x3000+0x50 > nul
# pad out the menu entries to right-align them
call /rtl.g4b
# display the new menu
configfile (md)0x3000+0x50


Note that the rtl.g4b batch file requires a recent version of grub4dos (I recommend 0.4.6a 2015-06-05 at the moment as this is currently used by E2B and seems stable).
It is also best to turn off the menu auto-numbering and menu pointer symbol too.




No comments:

Post a Comment