1. [tutor] こんにちは世界。 "Hello World"
- Posted by _tom (admin) Feb 26, 2019
- 1525 views
A console example
The oE|Phix programming languages are written in plain text.
You can use any people language for the name of your program file and string data.
In these examples I used google translate to make Euphoria programs that operate in Japanese.
-- oE include std/console.e atom answer = prompt_number("続行するには1を入力してください。", {} ) if answer = 1 then puts(1, "こんにちは世界。") else puts(1, "さようなら。" ) end if
Phix has "autoinclude" so it is a bit simpler.
--Phix atom answer = prompt_number("続行するには1を入力してください。", {} ) if answer = 1 then puts(1, "こんにちは世界。") else puts(1, "さようなら。" ) end if
Google translate provided
続行するには1を入力してください。 | Please enter 1 to continue. |
こんにちは世界。 | Hello world. |
さようなら。 | Goodbye. |
An example using oE and euGTK.
I saved the following file as こんにちは世界 . The file name こんにちは世界 now shows up in the title bar of the GTK window.
The "Quit" button is still English. You could invent your own buttons if you wish.
---------------------------------------------------------------------------- --# Yet Another Hello World! program ---------------------------------------------------------------------------- include GtkEngine.e constant --[1] create the widgets; win = create(GtkWindow,"border width=10,icon=face-laugh,$destroy=Quit"), pan = create(GtkBox,"orientation=vertical"), box = create(GtkButtonBox), btn = create(GtkButton,"gtk-quit", "Quit"), lbl = create(GtkLabel,"color=blue") --[2] style the label; set(lbl,"markup", -- style the text using basic html; "<b><u><span color='red'><big>こんにちは世界</big></span></u></b>\n\n" & "これは、ラベルと終了ボタンを持つ単純なウィンドウをデモします。\n") --[3] add widgets to containers; add(win,pan) add(pan,lbl) add(box,btn) pack(pan,-box) show_all(win) --[4] instantiate widgets; main() --[5] enter main processing loop;
You can customize an oE|Phix program for any people language with little effort. You do not have to fully understand UTF and fonts to make this happen.
_tom
2. Re: [tutor] こんにちは世界。 "Hello World"
- Posted by irv Feb 26, 2019
- 1348 views
In EuGTK, you can use any image and any caption on a button:
btn = create(GtkButton,"gtk-quit#さようなら。","Quit") -- stock "quit" icon
The stock icon (or image file) is first, followed by a pound sign (#) and then the caption.
btn = create(GtkButton,"~/demos/thumbnails/mongoose.png#さようなら。","Quit") -- image from file
There's also a way to change captions using an .ini file, which means a single program can change languages without changes to the source code. Users can modify the captions to their favorite languages very easily. Example:
-- Μετάφραση από την Google --! MainWindow.title = Δοκιμή αριθμού προγράμματος 3 --! MainWindow.border = 10 + MainWindow.HelpCaption = Βοήθεια + MainWindow.HelpTitle = Σχετικά με αυτό το πρόγραμμα + MainWindow.HelpText = Δεν υπάρχει τίποτα να πει κανείς, | είναι απλά ένα πρόγραμμα, ok?If they run your program without an .ini, your program reverts to english. You can have more than one .ini, one for each language.
See /demos/examples/misc/multi.ex
3. Re: [tutor] こんにちは世界。 "Hello World"
- Posted by _tom (admin) Feb 26, 2019
- 1268 views
Thanks Irv.
My conclusion is that rather than worry about "fonts" or "bytes per character" or other "details"--you can just use strings in the language you want.
_tom