1. HOWTO make EU bilingual
- Posted by kinz Sep 26, 2019
- 1363 views
If you want to have some tips on subject,
Rob and me opened the source of bilingual EU2.5 (en & ru).
Try please:
http://pl-euphoria.narod.ru/source25.zip
http://pl-euphoria.narod.ru/
All changes to pure RDS code are marked by
"kinz" comments.
Regards
kinz
2. Re: HOWTO make EU bilingual
- Posted by SDPringle Feb 09, 2020
- 1136 views
The error messaging in the Euphoria source code was designed to work with alternative languages.
See msgtext.e in the source.
public function GetMsgText( message_index MsgNum, integer WithNum = 1, object Args = {}) integer idx = 1 object msgtext -- First check localization databases msgtext = get_text( MsgNum, LocalizeQual, LocalDB ) -- If not found, scan through hard-coded messages
Put this in your source directory in your EUPHORIA distribution and run it. You can translate all of the 200+ strings this way, with cutting and paste mostly. Consider changing the code so you can modify string, or only do a few a day instead of all at once. And also consider converting this to use some GUI.
When you run it will ask for a language code. Russian will be 'ru'.
The program will create a file called teksto_ru.eds, (if you choose 'ru') and you can put this in your %EUDIR%\bin directory (or where eui resides) and then all of the message strings will be in the language you translated the strings to.
You'll need to add '-l ru' to the end of the eu.cfg file (also in %EUDIR%\bin) in order for it to use Russian by default.
include std/locale.e as locale include std/pretty.e include std/eds.e include std/io.e include ../source/msgtext.e include std/console.e include std/pretty.e include std/os.e include std/filesys.e sequence language object line line = prompt_string("Enter the two-letter code for the target language you are converting: ") language = line constant new_db_name = "teksto_" & line constant db_name = "newdb" integer open_error while open_error != DB_OK and open_error != DB_EXISTS_ALREADY with entry do object errs = db_get_errors() printf(2, "Couldn't create the database. Error %d\n", open_error) if length(errs) != 0 then for i = 1 to length(errs) do puts(2, errs[i] & 10) end for end if puts(2, "Trying again in five seconds...\n") sleep(5) entry open_error = eds:db_create(db_name) end while if open_error = DB_EXISTS_ALREADY then open_error = db_open(db_name) end if db_select(db_name) db_create_table("1") if db_select_table("1") != DB_OK then printf(2, "Cannot select table 1.\n") abort(1) end if object last_message = 0 integer msgnum = 0 while 1 do sequence english = GetMsgText(msgnum, 0, {"[1]", "[2]", "[3]", "[4]"}) if equal(last_message, english) then exit end if puts(1, "en: " & english & '\n') line = prompt_string(language &": ") -- GetMsgText uses eds, so we must select the db and table for each entry db_select(db_name) db_select_table("1") db_insert(msgnum, line) last_message = english msgnum += 1 end while eds:db_close() move_file(db_name, new_db_name)