diff --git a/lang/translations.csv b/lang/translations.csv new file mode 100644 index 0000000..2e2f57c --- /dev/null +++ b/lang/translations.csv @@ -0,0 +1,42 @@ +keys,en,zh,ja +CHAPTER_PATTERN,"Ch. %d %s","第 %d 章 %s","" +CHAPTER_NAME_0,"=P","=P","=P" +CHAPTER_NAME_1,"Add and Multiply","加法和乘法","" +CHAPTER_NAME_2,"()","()","" +CHAPTER_NAME_3,"Equal?","相等?","" +CHAPTER_NAME_4,"<>","<>","" +CHAPTER_NAME_5,"Extra Challenges","额外挑战","" + +LEVEL_NAME_0_0,"P=P","P=P","P=P" +LEVEL_NAME_0_1,"=P","=P","=P" +LEVEL_NAME_0_2,"Another Smile","Another Smile","Another Smile" +LEVEL_NAME_0_3,"Reverse","Reverse","Reverse" +LEVEL_NAME_0_4,"Reverse Again","Reverse Again","Reverse Again" +LEVEL_NAME_0_5,"Snake","Snake","Snake" + +LEVEL_NAME_1_0,"0+0=0, 0+1=1","0+0=0, 0+1=1","0+0=0, 0+1=1" +LEVEL_NAME_1_1,"1+1=1","1+1=1","1+1=1" +LEVEL_NAME_1_2,"Swap","交换","Swap" +LEVEL_NAME_1_3,"Always True","Always True","Always True" +LEVEL_NAME_1_4,"Paper Tiger","纸老虎","Paper Tiger" +LEVEL_NAME_1_5,"Make Me Laugh","Make Me Laugh","Make Me Laugh" +LEVEL_NAME_1_6,"Reset","重置","Reset" +LEVEL_NAME_1_7,"Not Necessary","并非必要","Not Necessary" +LEVEL_NAME_1_8,"True Reset","真正的重置","True Reset" +LEVEL_NAME_1_9,"Gold Experience","黄金体验","Gold Experience" + +LEVEL_NAME_2_0,"He Goes First","He Goes First","He Goes First" +LEVEL_NAME_2_1,"Still, He Goes First","Still, He Goes First","Still, He Goes First" +LEVEL_NAME_2_2,"It's My Turn","It's My Turn","It's My Turn" + +LEVEL_NAME_3_0,"Missing Equation","缺失的等式","Missing Equation" +LEVEL_NAME_3_1,"Why?","Why?","Why?" +LEVEL_NAME_3_2,"Where is the Equation?","Where is the Equation?","Where is the Equation?" +LEVEL_NAME_3_3,"Untitled","Untitled","Untitled" + +LEVEL_NAME_4_0,"<","<","<" +LEVEL_NAME_4_1,"<=","<=","<=" +LEVEL_NAME_4_2,"<>","<>","<>" + +LEVEL_NAME_5_0,"[EX] Erase Which?","[EX] Erase Which?","[EX]Erase Which?" +LEVEL_NAME_5_1,"[EX] Really Challenging","[EX] Really Challenging","[EX] Really Challenging" \ No newline at end of file diff --git a/lang/translations.csv.import b/lang/translations.csv.import new file mode 100644 index 0000000..5dbcc73 --- /dev/null +++ b/lang/translations.csv.import @@ -0,0 +1,17 @@ +[remap] + +importer="csv_translation" +type="Translation" +uid="uid://g1rl4ude18st" + +[deps] + +files=["res://lang/translations.en.translation", "res://lang/translations.zh.translation", "res://lang/translations.ja.translation"] + +source_file="res://lang/translations.csv" +dest_files=["res://lang/translations.en.translation", "res://lang/translations.zh.translation", "res://lang/translations.ja.translation"] + +[params] + +compress=true +delimiter=0 diff --git a/lang/translations.en.translation b/lang/translations.en.translation new file mode 100644 index 0000000..955bc82 Binary files /dev/null and b/lang/translations.en.translation differ diff --git a/lang/translations.ja.translation b/lang/translations.ja.translation new file mode 100644 index 0000000..0709d83 Binary files /dev/null and b/lang/translations.ja.translation differ diff --git a/lang/translations.zh.translation b/lang/translations.zh.translation new file mode 100644 index 0000000..0fef682 Binary files /dev/null and b/lang/translations.zh.translation differ diff --git a/levels/base_level/base_level.gd b/levels/base_level/base_level.gd index e35f8fa..03be371 100644 --- a/levels/base_level/base_level.gd +++ b/levels/base_level/base_level.gd @@ -42,12 +42,12 @@ func init(_chap_id: int, _lvl_id: int) -> void: chap_id = _chap_id lvl_id = _lvl_id - var lvl_name = LevelData.LEVEL_DATA[chap_id][lvl_id]["name-en"] + var lvl_name = "LEVEL_NAME_%d_%d" % [chap_id, lvl_id] var question = LevelData.LEVEL_DATA[chap_id][lvl_id]["question"].replace(" ", "").replace("X", "*") var choices = count(LevelData.LEVEL_DATA[chap_id][lvl_id]["choices"].replace(" ", "").replace("X", "*")) - $HUDs/Title.set_text("%d-%d %s" % [chap_id + 1, lvl_id + 1, lvl_name]) + $HUDs/Title.set_text("%d-%d %s" % [chap_id + 1, lvl_id + 1, tr(lvl_name)]) question = question.replace("[]", ".") diff --git a/levels/chapter_menu/level_menu/level_menu.gd b/levels/chapter_menu/level_menu/level_menu.gd index 67c639a..fb8e98a 100644 --- a/levels/chapter_menu/level_menu/level_menu.gd +++ b/levels/chapter_menu/level_menu/level_menu.gd @@ -15,7 +15,7 @@ const button_heigth : int = 50 func init(chap_id: int) -> void: self.chapter_id = chap_id - $UI/Title.text = LevelData.CHAP_NAMES[chapter_id]["name-en"] + $UI/Title.text = tr("CHAPTER_PATTERN") % [chap_id + 1, tr("CHAPTER_NAME_%d" % chap_id)] $LevelMenuCamera.init_position(Vector2(WIDTH * chap_id, 0)) $UI/PreviousChapterButton.set_disabled(chapter_id == 0) @@ -42,7 +42,7 @@ func _on_button_enter_level(chap_id: int, lvl_id: int) -> void: func _on_previous_chapter_button_pressed(): self.chapter_id -= 1 - $UI/Title.text = LevelData.CHAP_NAMES[chapter_id]["name-en"] + $UI/Title.text = tr("CHAPTER_PATTERN") % [self.chapter_id + 1, tr("CHAPTER_NAME_%d" % self.chapter_id)] ImageLib.change_theme(ImageLib.COLOR_THEMES[ImageLib.COLOR_THEMES.find(ImageLib.theme_to) - 1], LevelMenuCamera.MOVE_TIME) $UI/PreviousChapterButton.set_disabled(true) $UI/NextChapterButton.set_disabled(true) @@ -51,7 +51,7 @@ func _on_previous_chapter_button_pressed(): func _on_next_chapter_button_pressed(): self.chapter_id += 1 ImageLib.change_theme(ImageLib.COLOR_THEMES[ImageLib.COLOR_THEMES.find(ImageLib.theme_to) + 1], LevelMenuCamera.MOVE_TIME) - $UI/Title.text = LevelData.CHAP_NAMES[chapter_id]["name-en"] + $UI/Title.text = tr("CHAPTER_PATTERN") % [self.chapter_id + 1, tr("CHAPTER_NAME_%d" % self.chapter_id)] $UI/PreviousChapterButton.set_disabled(true) $UI/NextChapterButton.set_disabled(true) diff --git a/project.godot b/project.godot index 7aaae05..c719cf1 100644 --- a/project.godot +++ b/project.godot @@ -40,6 +40,10 @@ enabled=PackedStringArray("res://addons/AsepriteWizard/plugin.cfg") theme/custom="res://themes/default_theme.tres" theme/custom_font="res://fonts/Silver.ttf" +[internationalization] + +locale/translations=PackedStringArray("res://lang/translations.en.translation", "res://lang/translations.ja.translation", "res://lang/translations.zh.translation") + [rendering] textures/canvas_textures/default_texture_filter=0 diff --git a/scripts/level_data.gd b/scripts/level_data.gd index 0556258..f5a2730 100644 --- a/scripts/level_data.gd +++ b/scripts/level_data.gd @@ -2,32 +2,6 @@ class_name LevelData - -## 各章节的名称。 -## [br][br] -## [code]CHAP_NAMES[chapter_id]["name-en"][/code] 返回第 [param chapter_id] 章节的英文名称(包含 [code]Ch.[/code] 前缀)。 -const CHAP_NAMES := [ - { - "name-en": "Ch. 1 =P", - }, - { - "name-en": "Ch. 2 Add and Multiply", - }, - { - "name-en": "Ch. 3 ()", - }, - { - "name-en": "Ch. 4 Equal?", - }, - { - "name-en": "Ch. 5 <>", - }, - { - "name-en": "Ch. EX Challenge Levels", - } -] - - ## 各关卡的关卡数据。 ## [br][br] ## [code]LEVEL_DATA[chapter_id][level_id] : Dictionary[/code] 返回第 [param chapter_id] 章节的第 [param level_id] 关卡的关卡数据,以下记为 [code]data[/code]。其中: @@ -40,32 +14,26 @@ const CHAP_NAMES := [ const LEVEL_DATA := [ [ { - "name-en": "=P", "question": "P [] []", "choices": "= P" }, { - "name-en": "Smile", "question": "P {} {}", "choices": "= P P" }, { - "name-en": "Another Smile", "question": "[] = {}", "choices": "R R P D D" }, { - "name-en": "Reverse", "question": "{} [] []", "choices": "D D = d d" }, { - "name-en": "Reverse Again", "question": "[] {} {}", "choices": "d d = R R b b" }, { - "name-en": "Snake", "question": "[] = {} = {} = [] = {} = {}", "choices": "dddddd QQQQQQ RRRRRR DDDDDD PPPPPP qqqqqq" } @@ -73,52 +41,42 @@ const LEVEL_DATA := [ [ { - "name-en": "0+0=0, 0+1=1", "question": "[] [] {} {} d", "choices": "= + 0 d" }, { - "name-en": "1+1=1", "question": "[] [] {} {} 1", "choices": "= + 1 d" }, { - "name-en": "Swap", "question": "Q + [] = {} + []", "choices": "P P P P Q Q Q Q" }, { - "name-en": "Always True", "question": "1 [] {} = {} [] []", "choices": "1++PPdd" }, { - "name-en": "Paper Tiger", "question": "1 [] [] [] {} [] [] [] {} [] {} [] []", "choices": "== ++++++ 11 P q b R" }, { - "name-en": "Make Me Laugh", "question": "1 {} {} = []", "choices": "XDD" }, { - "name-en": "Reset", "question": "0 [] [] {} []", "choices": "XP=0" }, { - "name-en": "Not Necessary", "question": "[] {} {} {} {} []", "choices": "QQQQQQ DDXX=" }, { - "name-en": "True Reset", "question": "[] + [] [] [] [] {} = {} [] [] [] [] [] []", "choices": "0 0 1 d d q P P b R R Q +" }, { - "name-en": "Gold Experience", "question": "{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}", "choices": "PP DD bb qq dd XXXXX =" }, @@ -126,17 +84,14 @@ const LEVEL_DATA := [ [ { - "name-en": "He Goes First", "question": "[] [] + [] = ( [] {} {} ) [] []", "choices": "PP QQ RR X +" }, { - "name-en": "Still, He Goes First", "question": "[] + [] [] = [] [] ( [] {} {} )", "choices": "PP QQ RR X +" }, { - "name-en": "It's My Turn", "question": "P ([] [] []) = {} [] [] [] []", "choices": "PP QQ RR ++" }, @@ -144,23 +99,19 @@ const LEVEL_DATA := [ [ { - "name-en": "Missing Equation", "question": "[] + [] {} {}", "choices": "P P P 1 X", }, { - "name-en": "Why?", "question": "[] [] {} = {} [] {} = []", "choices": "PP qq ++ 1" }, { - "name-en": "Where is the Equation?", "question": "[] [] {} {} [] + [] [] {} {} []", "choices": "(())==01PP" }, { - "name-en": "Untitled", "question": "[] [] {} {} [] [] [] []", "choices": "=PPQQ+()" } @@ -168,29 +119,24 @@ const LEVEL_DATA := [ [ { - "name-en": "<", "question": "0 {} {} [] 1", "choices": "XD<" }, { - "name-en": "<=", "question": "[] X [] {} {} [] + []", "choices": "QQPP<=" }, { - "name-en": "<>", "question": "0 {} P [] [] []", "choices": "<>=P" } ], [ { - "name-en": "[EX]Erase Which?", "question": "[] {} {} [] [] [] [] {} {} {} {} {} [] [] [] [] [] []", "choices": "0 X D + P + P d = P X P + 0 d + P d", }, { - "name-en": "[EX] Really Challenging", "question": "[] [] [] [] [] {} {} [] [] [] [] {} {} + [] []", "choices": "PPP QQ DD (()) ++ = X" },