VN game

I have started to write a new VN game but this time I want my script file to be translate into Thai language, This is what I have done:
screen main_menu:

    tag menu

    window:
        style "mm_root"

    frame:
        style_group "mm"
        xalign .98
        yalign .98

        has vbox
        
        if lang == "english":
            textbutton _("Start Game") action Start()
            textbutton _("Load Game") action ShowMenu("load")
            textbutton _("Preferences") action ShowMenu("preferences")
            textbutton _("Help") action Help()
            textbutton _("Quit") action Quit(confirm=False)
        elif lang == "thai":
            textbutton _("เริ่มเกม") action Start()
            textbutton _("โหลดเกม") action ShowMenu("load")
            textbutton _("การตั้งค่า") action ShowMenu("preferences")
            textbutton _("ช่วย") action Help()
            textbutton _("เลิก") action Quit(confirm=False)

init -2:
    style mm_button:
        size_group "mm"[/ICODE]

[ICODE]screen navigation:

    window:
        style "gm_root"

    frame:
        style_group "gm_nav"
        xalign .98
        yalign .98

        has vbox
        
        if lang == "english":
            textbutton _("Return") action Return()
            textbutton _("Preferences") action ShowMenu("preferences")
            textbutton _("Save Game") action ShowMenu("save")
            textbutton _("Load Game") action ShowMenu("load")
            textbutton _("Main Menu") action MainMenu()
            textbutton _("Help") action Help()
            textbutton _("Quit") action Quit()
        elif lang == "thai":
            textbutton _("กลับ") action Return()
            textbutton _("การตั้งค่า") action ShowMenu("preferences")
            textbutton _("บันทึกเกม") action ShowMenu("save")
            textbutton _("โหลดเกม") action ShowMenu("load")
            textbutton _("เมนูหลัก") action MainMenu()
            textbutton _("ช่วย") action Help()
            textbutton _("เลิก") action Quit()

init -2:
    style gm_nav_button:
        size_group "gm_nav"[/ICODE]

[ICODE]screen file_picker:

    frame:
        style "file_picker_frame"

        has vbox

        hbox:
            style_group "file_picker_nav"

        if lang == "english":       
            textbutton _("Previous"):
                action FilePagePrevious()

            textbutton _("Auto"):
                action FilePage("auto")

            textbutton _("Quick"):
                action FilePage("quick")

            for i in range(1, 9):
                textbutton str(i):
                    action FilePage(i)

            textbutton _("Next"):
                action FilePageNext()
                
         elif lang == "thai":
            textbutton _("<xton>Previous"):
                action FilePagePrevious()

            textbutton _("<xton>Auto"):
                action FilePage("auto")

            textbutton _("<xton>Quick"):
                action FilePage("quick")

            for i in range(1, 20):
                textbutton str(i):
                    action FilePage(i)
                    
            textbutton _("<xton>Next"):
                action FilePageNext()

        $ columns = 2
        $ rows = 8[/ICODE]

[ICODE]screen preferences:

    tag menu

    use navigation

    grid 3 1:
        style_group "prefs"
        xfill True

        vbox:
            frame:
                style_group "pref"
                has vbox

                 if lang == "english":
                    label _("Display")
                    textbutton _("Window") action Preference("display", "window")
                    textbutton _("Full Screen") action Preference("display", "fullscreen")
                elif lang == "thai":
                    label _("Display")
                    textbutton _("Window") action Preference("display", "window")
                    textbutton _("Full Screen") action Preference("display", "fullscreen")

With these codes I can choose the language from the "Preference" but what I want to ask is that, how to create another page containing 2 vbox like there are in Preference above but an entirely different page, a page before a main menu page?

Comments

  • You should be storing all of your language strings into a resource table (xml file, etc), and references those from your code by a key. When the program loads, based on your language selection or preference, the correct language table will be loaded.

    This way you do not need all these case statements everywhere in your code, and you code will be language independent, making it very easier to add new ones in the future (with no code changes).
  • how do i create a resource table?
  • http://docs.python.org/2/library/i18n.html

    Or if you want to roll your own, you could just store all your string in an XML file and read from that.
  • this is online or stand alone table?
Sign In or Register to comment.