Skip to content

Commit

Permalink
Add Russian translation (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
kagalenko-m-b authored Sep 11, 2024
1 parent 2733205 commit 8efd18f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 18 deletions.
3 changes: 2 additions & 1 deletion example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ 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",
"ru"=>"Russian"]) )
"""

# ╔═╡ 657c3eea-1ef6-11ed-3e82-5daad2bc19a1
Expand Down
38 changes: 21 additions & 17 deletions src/i18n/i18n.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,33 @@ include("english.jl")
import .PTTEnglish: EnglishUS
include("german.jl")
import .PTTGerman: GermanGermany, GermanGermanyFormal, GermanGermanyColloquial
include("russian.jl")
import .PTTRussian: RussianRU
include("spanish.jl")
import .PTTSpanish: SpanishES, SpanishFormal, SpanishColloquial

const languages_registered = Ref{Dict{String,AbstractLanguage}}(
Dict( "en" => PTTEnglish.EnglishUS(),
"en_us" => PTTEnglish.EnglishUS(),
"de" => PTTGerman.GermanGermany(),
"de_colloq" => PTTGerman.GermanGermanyColloquial(),
"de_de" => PTTGerman.GermanGermany(),
"de_de_colloq" => PTTGerman.GermanGermanyColloquial(),
"es" => PTTSpanish.SpanishES(),
"es_colloq" => PTTSpanish.SpanishColloquial(),
"es_es" => PTTSpanish.SpanishES(),
"es_es_colloq" => PTTSpanish.SpanishColloquial(),
))
Dict( "en" => PTTEnglish.EnglishUS(),
"en_us" => PTTEnglish.EnglishUS(),
"de" => PTTGerman.GermanGermany(),
"de_colloq" => PTTGerman.GermanGermanyColloquial(),
"de_de" => PTTGerman.GermanGermany(),
"de_de_colloq" => PTTGerman.GermanGermanyColloquial(),
"ru" => PTTRussian.RussianRU(),
"es" => PTTSpanish.SpanishES(),
"es_colloq" => PTTSpanish.SpanishColloquial(),
"es_es" => PTTSpanish.SpanishES(),
"es_es_colloq" => PTTSpanish.SpanishColloquial(),
))

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"]
))
Dict( PTTEnglish.EnglishUS() => ["en","en_us"],
PTTGerman.GermanGermany() => ["de","de_de"],
PTTGerman.GermanGermanyColloquial() => ["de_colloq", "de_de_colloq"],
PTTRussian.RussianRU() => ["ru","ru_ru"],
PTTSpanish.SpanishES() => ["es", "es_es"],
PTTSpanish.SpanishColloquial() => ["es_colloq", "es_es_colloq"]
))

# Allow users to register additional languages
function register_language!(str::AbstractString, lang::Lang) where { Lang <: AbstractLanguage }
Expand Down
60 changes: 60 additions & 0 deletions src/i18n/russian.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module PTTRussian

using Markdown

using ..PlutoTeachingTools

abstract type Russian <: AbstractLanguage end
struct RussianRU <: Russian end

# computational_thinking.jl
PlutoTeachingTools.hint_str(lang::Lang) where {Lang <: Russian} = "Подсказка"
PlutoTeachingTools.tip_str(lang::Lang) where {Lang <: Russian} = "Совет"
PlutoTeachingTools.protip_invite_str(lang::Lang) where {Lang <: Russian} = "Хотите узнать больше?"
PlutoTeachingTools.protip_boxlabel_str(lang::Lang) where {Lang <: Russian} = "Совет профессионала"
PlutoTeachingTools.answer_invite_str(lang::Lang) where {Lang <: Russian} = "Хотите посмотреть ответ?"
PlutoTeachingTools.answer_boxlabel_str(lang::Lang) where {Lang <: Russian} = "Ответ"
PlutoTeachingTools.almost_str(lang::Lang) where {Lang <: Russian} = "Почти правильно!"
PlutoTeachingTools.warning_box_str(lang::Lang) where {Lang <: Russian} = "Внимание:"
PlutoTeachingTools.question_box_str(lang::Lang) where {Lang <: Russian} = "Вопрос:"
PlutoTeachingTools.danger_str(lang::Lang) where {Lang <: Russian} = "Осторожно!"
PlutoTeachingTools.keyconcept_str(lang::Lang) where {Lang <: Russian} = "🎯 Ключевое понятие"
PlutoTeachingTools.still_missing_str(lang::Lang) where {Lang <: Russian} = "Отсутствующий ответ"
PlutoTeachingTools.still_missing_text_str(lang::Lang) where {Lang <: Russian} = md"Замените `missing` на ваш ответ."
PlutoTeachingTools.still_nothing_str(lang::Lang) where {Lang <: Russian} = "Начинаем!"
PlutoTeachingTools.still_nothing_text_str(lang::Lang) where {Lang <: Russian} = md"Замените `nothing` на ваш ответ."
PlutoTeachingTools.wrong_type_str(lang::Lang) where {Lang <: Russian} = "Ошибка типа"
PlutoTeachingTools.wrong_type_text_str(lang::Lang) where {Lang <: Russian} = md"Проверьте тип вашего ответа."
PlutoTeachingTools.wrong_type_text_str(lang::Lang, var, type) where {Lang <: Russian} = md"Тип $var должен быть $type"
PlutoTeachingTools.func_not_defined_str(lang::Lang) where {Lang <: Russian} = "Ой!"
PlutoTeachingTools.func_not_defined_text_str(func_name, lang::Lang) where {Lang <: Russian} = md"Убедитесь, что вы определили функцию под названием **$(Markdown.Code(string(func_name)))**"
PlutoTeachingTools.var_not_defined_str(lang::Lang) where {Lang <: Russian} = "Ой!"
PlutoTeachingTools.var_not_defined_text_str(variable_name, lang::Lang) where {Lang <: Russian} = md"Убедитесь, что вы определили переменную под названием **$(Markdown.Code(string(variable_name)))**"
PlutoTeachingTools.keep_working_str(lang::Lang) where {Lang <: Russian} = "Продолжайте работу!"
PlutoTeachingTools.keep_working_text_str(lang::Lang) where {Lang <: Russian} = md"Ответ не вполне правильный."
PlutoTeachingTools.keep_working_update_str(var, lang::Lang) where {Lang <: Russian} = md"Обязательно обновите параметр ячейки $var."
PlutoTeachingTools.yays(lang::Lang) where {Lang <: Russian} = [md"Отлично!", md"Ура ❤", md"Здорово! 🎉", md"Молодец!", md"Продолжайте в том же духе!", md"Хорошая работа!", md"Здорово!", md"Получен правильный ответ!", md"Переходим к следующему разделу"]
PlutoTeachingTools.correct_str(lang::Lang) where {Lang <: Russian} = "Получилось!"
PlutoTeachingTools.todo_str(lang::Lang) where {Lang <: Russian} = "НУЖНО СДЕЛАТЬ"

PlutoTeachingTools.check_type_isa_missing_text_str(sym, lang::Lang) where {Lang <: Russian} = md"Переменная $sym по-прежнему имеет значение `missing`."
PlutoTeachingTools.check_type_isa_wrong_type_text_str(sym, lang::Lang) where {Lang <: Russian} = "Тип $sym задан неверно. Он должен быть <: "
PlutoTeachingTools.check_type_isa_wrong_type_one_of_text_str(lang::Lang) where {Lang <: Russian} = "один из"
PlutoTeachingTools.check_type_isa_wrong_type_or_text_str(lang::Lang) where {Lang <: Russian} = "или"
PlutoTeachingTools.check_type_isa_not_missing_text_str(sym, lang::Lang) where {Lang <: Russian} = md"тип переменной $sym правильный."
PlutoTeachingTools.check_type_isa_type_error_str(sym, lang::Lang) where {Lang <: Russian} = "Ошибка типа"

PlutoTeachingTools.check_type_eq_missing_text_str(sym, lang::Lang) where {Lang <: Russian} = md"Переменная $sym по-прежнему имеет значение `missing`."
PlutoTeachingTools.check_type_eq_wrong_type_single_text_str(sym, type, lang::Lang) where {Lang <: Russian} = "Тип переменной $sym должен быть $type."
PlutoTeachingTools.check_type_eq_wrong_type_multi_text_str(sym, lang::Lang) where {Lang <: Russian} = "Тип переменной $sym должен быть один из "
PlutoTeachingTools.check_type_eq_type_error_str(lang::Lang) where {Lang <: Russian} = "Ошибка типа"
PlutoTeachingTools.check_type_eq_correct_str(sym, lang::Lang) where {Lang <: Russian} = md"тип переменной $sym правилен."

# other.jl
PlutoTeachingTools.full_width_mode_str(lang::Lang) where {Lang <: Russian} = "Режим полной ширины"

# present.jl
PlutoTeachingTools.present_str(lang::Lang) where {Lang <: Russian} = "презентация"
PlutoTeachingTools.present_mode_str(lang::Lang) where {Lang <: Russian} = "Режим презентации"

end

0 comments on commit 8efd18f

Please sign in to comment.