Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Chinese Translation. #45

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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"]) )
Language for common prompts: $(@bind lang Select(["en"=>"English","de"=>"German","es"=>"Spanish","zh"=>"chinese"]) )
"""

# ╔═╡ 657c3eea-1ef6-11ed-3e82-5daad2bc19a1
Expand Down
60 changes: 60 additions & 0 deletions src/i18n/chinese.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module PTTChinese

using Markdown

using ..PlutoTeachingTools

abstract type Chinese <: AbstractLanguage end
struct zh-CN <: 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} = "类型错误Type Error"
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"Great!", md"Yay ❤", md"Great! 🎉", md"Well done!", md"Keep it up!", md"Good job!", md"Awesome!", md"You got the right answer!", md"Let's move on to the next part."]
PlutoTeachingTools.correct_str(lang::Lang) where {Lang <: Chinese} = "Got it!"
PlutoTeachingTools.todo_str(lang::Lang) where {Lang <: Chinese} = "TODO"
Comment on lines +36 to +38
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these are still missing translations.


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} = "类型错误Type Error"

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} = "类型错误Type Error"
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
14 changes: 13 additions & 1 deletion src/i18n/i18n.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ include("german.jl")
import .PTTGerman: GermanGermany, GermanGermanyFormal, GermanGermanyColloquial
include("spanish.jl")
import .PTTSpanish: SpanishES, SpanishFormal, SpanishColloquial
include("chinese.jl")
import .PTTChinese: SimplifiedChinese


abstract type German <: AbstractLanguage end
struct GermanGermanyFormal <: German end
struct GermanGermanyColloquial <: German end
GermanGermany = GermanGermanyFormal

Comment on lines +65 to +70
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be removed. They are imported in L59 and unrelated to the Chinese translation.

Suggested change
abstract type German <: AbstractLanguage end
struct GermanGermanyFormal <: German end
struct GermanGermanyColloquial <: German end
GermanGermany = GermanGermanyFormal


const languages_registered = Ref{Dict{String,AbstractLanguage}}(
Dict( "en" => PTTEnglish.EnglishUS(),
Expand All @@ -71,14 +80,17 @@ const languages_registered = Ref{Dict{String,AbstractLanguage}}(
"es_colloq" => PTTSpanish.SpanishColloquial(),
"es_es" => PTTSpanish.SpanishES(),
"es_es_colloq" => PTTSpanish.SpanishColloquial(),
"zh" => PTTChinese.SimplifiedChinese(),
"zh_CN" => PTTChinese.SimplifiedChinese(),
))

const language_codes_registered = Ref{Dict{AbstractLanguage,Vector{String}}}(
Dict( PTTEnglish.EnglishUS() => ["en","en_us"],
PTTGerman.GermanGermany() => ["de","de_de"],
PTTGerman.GermanGermanyColloquial() => ["de_colloq", "de_de_colloq"],
PTTSpanish.SpanishES() => ["es", "es_es"],
PTTSpanish.SpanishColloquial() => ["es_colloq", "es_es_colloq"]
PTTSpanish.SpanishColloquial() => ["es_colloq", "es_es_colloq"],
PTTChinese.SimplifiedChinese() => ["zh", "zh_CN"]
))

# Allow users to register additional languages
Expand Down