From 22a4b13e59ee756ec1ff23ed225c2cf3e75fd1e9 Mon Sep 17 00:00:00 2001 From: mathutopia Date: Thu, 12 Sep 2024 20:44:34 +0800 Subject: [PATCH 1/2] Chinese Translation. --- example.jl | 2 +- src/i18n/chinese.jl | 60 +++++++++++++++++++++++++++++++++++++++++++++ src/i18n/i18n.jl | 6 ++++- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 src/i18n/chinese.jl diff --git a/example.jl b/example.jl index 26ed430..753fae3 100644 --- a/example.jl +++ b/example.jl @@ -23,7 +23,7 @@ md"# [PlutoTeachingTools.jl](https://github.com/JuliaPluto/PlutoTeachingTools.jl # ╔═╡ 84ccb960-41f8-430d-bd73-a7c0248cfb95 md""" Language for common prompts: $(@bind lang Select(["en"=>"English","de"=>"German","es"=>"Spanish", -"ru"=>"Russian"]) ) +"ru"=>"Russian", "zh"=>"chinese"]]) ) """ # ╔═╡ 657c3eea-1ef6-11ed-3e82-5daad2bc19a1 diff --git a/src/i18n/chinese.jl b/src/i18n/chinese.jl new file mode 100644 index 0000000..8453e87 --- /dev/null +++ b/src/i18n/chinese.jl @@ -0,0 +1,60 @@ +module PTTChinese + +using Markdown + +using ..PlutoTeachingTools + +abstract type Chinese <: AbstractLanguage end +struct ChineseZH <: Chinese end + +# computational_thinking.jl +PlutoTeachingTools.hint_str(lang::Lang) where {Lang <: Chinese} = "提示" +PlutoTeachingTools.tip_str(lang::Lang) where {Lang <: Chinese} = "提醒" +PlutoTeachingTools.protip_invite_str(lang::Lang) where {Lang <: Chinese} = "想了解更多?" +PlutoTeachingTools.protip_boxlabel_str(lang::Lang) where {Lang <: Chinese} = "提醒" +PlutoTeachingTools.answer_invite_str(lang::Lang) where {Lang <: Chinese} = "想要看答案?" +PlutoTeachingTools.answer_boxlabel_str(lang::Lang) where {Lang <: Chinese} = "答案" +PlutoTeachingTools.almost_str(lang::Lang) where {Lang <: Chinese} = "差不多了!" +PlutoTeachingTools.warning_box_str(lang::Lang) where {Lang <: Chinese} = "警告:" +PlutoTeachingTools.question_box_str(lang::Lang) where {Lang <: Chinese} = "问题:" +PlutoTeachingTools.danger_str(lang::Lang) where {Lang <: Chinese} = "危险:" +PlutoTeachingTools.keyconcept_str(lang::Lang) where {Lang <: Chinese} = "🎯 核心概念" +PlutoTeachingTools.still_missing_str(lang::Lang) where {Lang <: Chinese} = "缺少回应" +PlutoTeachingTools.still_missing_text_str(lang::Lang) where {Lang <: Chinese} = md"把`missing`替换为你的答案." +PlutoTeachingTools.still_nothing_str(lang::Lang) where {Lang <: Chinese} = "让我们开始吧!" +PlutoTeachingTools.still_nothing_text_str(lang::Lang) where {Lang <: Chinese} = md"把 `nothing` 替换为你的答案." +PlutoTeachingTools.wrong_type_str(lang::Lang) where {Lang <: Chinese} = "类型错误" +PlutoTeachingTools.wrong_type_text_str(lang::Lang) where {Lang <: Chinese} = md"检查你的响应的类型." +PlutoTeachingTools.wrong_type_text_str(lang::Lang, var, type) where {Lang <: Chinese} = md"$var 的类型应该是 $type" +PlutoTeachingTools.func_not_defined_str(lang::Lang) where {Lang <: Chinese} = "糟糕!" +PlutoTeachingTools.func_not_defined_text_str(func_name, lang::Lang) where {Lang <: Chinese} = md"请确定你定义了一个名为 **$(Markdown.Code(string(func_name)))** 的函数。" +PlutoTeachingTools.var_not_defined_str(lang::Lang) where {Lang <: Chinese} = "糟糕!" +PlutoTeachingTools.var_not_defined_text_str(variable_name, lang::Lang) where {Lang <: Chinese} = md"请确定你定义了一个名为 **$(Markdown.Code(string(variable_name)))** 的变量。" +PlutoTeachingTools.keep_working_str(lang::Lang) where {Lang <: Chinese} = "继续加油!" +PlutoTeachingTools.keep_working_text_str(lang::Lang) where {Lang <: Chinese} = md"答案还不太对." +PlutoTeachingTools.keep_working_update_str(var, lang::Lang) where {Lang <: Chinese} = md"确保更新单元格设置 $var." +PlutoTeachingTools.yays(lang::Lang) where {Lang <: Chinese} = [md"很棒!", md"耶 ❤", md"很棒! 🎉", md"干得好", md"继续保持!", md"干得不错!", md"帅呆了", md"你做对了!", md"继续往下看吧."] +PlutoTeachingTools.correct_str(lang::Lang) where {Lang <: Chinese} = "懂了!" +PlutoTeachingTools.todo_str(lang::Lang) where {Lang <: Chinese} = "待办" + +PlutoTeachingTools.check_type_isa_missing_text_str(sym, lang::Lang) where {Lang <: Chinese} = md"变量 $sym 仍然被设置为 missing." +PlutoTeachingTools.check_type_isa_wrong_type_text_str(sym, lang::Lang) where {Lang <: Chinese} = "$sym 的类型不对. 它应该是 <: " +PlutoTeachingTools.check_type_isa_wrong_type_one_of_text_str(lang::Lang) where {Lang <: Chinese} = "一个" +PlutoTeachingTools.check_type_isa_wrong_type_or_text_str(lang::Lang) where {Lang <: Chinese} = "或者" +PlutoTeachingTools.check_type_isa_not_missing_text_str(sym, lang::Lang) where {Lang <: Chinese} = md"$sym 类型正确." +PlutoTeachingTools.check_type_isa_type_error_str(sym, lang::Lang) where {Lang <: Chinese} = "类型错误" + +PlutoTeachingTools.check_type_eq_missing_text_str(sym, lang::Lang) where {Lang <: Chinese} = md"变量 $sym 仍被置为 missing." +PlutoTeachingTools.check_type_eq_wrong_type_single_text_str(sym, type, lang::Lang) where {Lang <: Chinese} = "$sym 的类型应该是 $type." +PlutoTeachingTools.check_type_eq_wrong_type_multi_text_str(sym, lang::Lang) where {Lang <: Chinese} = "$sym 应该是一个 " +PlutoTeachingTools.check_type_eq_type_error_str(lang::Lang) where {Lang <: Chinese} = "类型错误" +PlutoTeachingTools.check_type_eq_correct_str(sym, lang::Lang) where {Lang <: Chinese} = md"$sym 类型正确." + +# other.jl +PlutoTeachingTools.full_width_mode_str(lang::Lang) where {Lang <: Chinese} = "全屏模式" + +# present.jl +PlutoTeachingTools.present_str(lang::Lang) where {Lang <: Chinese} = "演示" +PlutoTeachingTools.present_mode_str(lang::Lang) where {Lang <: Chinese} = "演示模式" + +end diff --git a/src/i18n/i18n.jl b/src/i18n/i18n.jl index de3d24b..99bcc19 100644 --- a/src/i18n/i18n.jl +++ b/src/i18n/i18n.jl @@ -61,6 +61,8 @@ include("russian.jl") import .PTTRussian: RussianRU include("spanish.jl") import .PTTSpanish: SpanishES, SpanishFormal, SpanishColloquial +include("chinese.jl") +import .PTTChinese: ChineseZH const languages_registered = Ref{Dict{String,AbstractLanguage}}( Dict( "en" => PTTEnglish.EnglishUS(), @@ -74,6 +76,7 @@ const languages_registered = Ref{Dict{String,AbstractLanguage}}( "es_colloq" => PTTSpanish.SpanishColloquial(), "es_es" => PTTSpanish.SpanishES(), "es_es_colloq" => PTTSpanish.SpanishColloquial(), + "zh" => PTTChinese.ChineseZH(), )) const language_codes_registered = Ref{Dict{AbstractLanguage,Vector{String}}}( @@ -82,7 +85,8 @@ const language_codes_registered = Ref{Dict{AbstractLanguage,Vector{String}}}( PTTGerman.GermanGermanyColloquial() => ["de_colloq", "de_de_colloq"], PTTRussian.RussianRU() => ["ru","ru_ru"], PTTSpanish.SpanishES() => ["es", "es_es"], - PTTSpanish.SpanishColloquial() => ["es_colloq", "es_es_colloq"] + PTTSpanish.SpanishColloquial() => ["es_colloq", "es_es_colloq"], + PTTChinese.ChineseZH() => ["zh", "zh-cn"] )) # Allow users to register additional languages From 03c8d73a372de08834eee7bab8c41187b3dc7574 Mon Sep 17 00:00:00 2001 From: mathutopia Date: Thu, 12 Sep 2024 13:23:00 +0000 Subject: [PATCH 2/2] Update src/i18n/i18n.jl Co-authored-by: Adrian Hill --- src/i18n/i18n.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/i18n.jl b/src/i18n/i18n.jl index 99bcc19..d9843d6 100644 --- a/src/i18n/i18n.jl +++ b/src/i18n/i18n.jl @@ -86,7 +86,7 @@ const language_codes_registered = Ref{Dict{AbstractLanguage,Vector{String}}}( PTTRussian.RussianRU() => ["ru","ru_ru"], PTTSpanish.SpanishES() => ["es", "es_es"], PTTSpanish.SpanishColloquial() => ["es_colloq", "es_es_colloq"], - PTTChinese.ChineseZH() => ["zh", "zh-cn"] + PTTChinese.ChineseZH() => ["zh", "zh_cn"] )) # Allow users to register additional languages