From 1cc44dd54fb02ea749f3462d4f9c8b7d5a00a41a Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 14 Apr 2019 17:49:25 +0200 Subject: [PATCH] mainmenu: translate main menu --- examples/mainmenu/init.lua | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/examples/mainmenu/init.lua b/examples/mainmenu/init.lua index 53ebfea..c4d6a99 100644 --- a/examples/mainmenu/init.lua +++ b/examples/mainmenu/init.lua @@ -36,15 +36,15 @@ function MainMenu:new() self.assets:addImageFont("medium", "examples/mainmenu/assets/medium") self:addMenu("main", true) - self:addSubMenu("basic", "Basic Tests") - self:addScene("basic", examples.Test, "Basic Test 1") - self:addScene("basic", examples.Test2, "Basic Test 2") - self:addScene("basic", examples.TestMenu, "Basic Test Menu") - self:addSubMenu("menus", "Menus Tests") - self:addScene("menus", examples.Inventory, "Inventory") - self:addScene("menus", examples.Options, "Options") - self:addSubMenu("gameplay", "Games Examples") - self:addScene("gameplay", examples.MovePlayer, "Movable Player") + self:addSubMenu("basic", "basic") + self:addScene("basic", examples.Test, "test1") + self:addScene("basic", examples.Test2, "test2") + self:addScene("basic", examples.TestMenu, "testmenu") + self:addSubMenu("menus", "menu") + self:addScene("menus", examples.Inventory, "inventory") + self:addScene("menus", examples.Options, "options") + self:addSubMenu("gameplay", "gameplay") + self:addScene("gameplay", examples.MovePlayer, "movable") ExitWidget(self, "main") self.menusystem:switchMenu("main") @@ -63,7 +63,7 @@ end function MainMenu:addSubMenu(name, fullname) self:addMenu(name) SubMenuWidget(self, "main", name, fullname) - SubMenuWidget(self, name, "main", "< Back", 1) + SubMenuWidget(self, name, "main", "back", 1) end function MainMenu:addScene(submenu, scene, fullname) @@ -85,7 +85,13 @@ function SubMenuWidget:new(scene, menu, newmenu, fullname, order) local widgetmenu = self.scene.menusystem.menus[menu] local font = self.scene.assets.fonts["medium"] self.newmenu = newmenu - SubMenuWidget.super.new(self, widgetmenu, font, fullname) + local label = "" + if fullname == "back" then + label = core.lang:translate("commons", fullname) + else + label = core.lang:translate("mainmenu", fullname) + end + SubMenuWidget.super.new(self, widgetmenu, font, label) self.order = order or 0 end @@ -100,7 +106,8 @@ function SceneWidget:new(scene, menu, newscene, fullname) local widgetmenu = self.scene.menusystem.menus[menu] local font = self.scene.assets.fonts["medium"] self.newscene = newscene - SceneWidget.super.new(self, widgetmenu, font, fullname) + local label = core.lang:translate("mainmenu", fullname) + SceneWidget.super.new(self, widgetmenu, font, label) end function SceneWidget:action() @@ -114,7 +121,8 @@ function ExitWidget:new(scene, menu) self.scene = scene local widgetmenu = self.scene.menusystem.menus[menu] local font = self.scene.assets.fonts["medium"] - SceneWidget.super.new(self, widgetmenu, font, "Exit") + local label = core.lang:translate("commons", "exit") + SceneWidget.super.new(self, widgetmenu, font, label) end function ExitWidget:action()