Skip to content

Commit

Permalink
Declent_ru updates and add support for reagent desc (#820)
Browse files Browse the repository at this point in the history
## About The Pull Request
Добавляет поддержку для описаний химикатов
Обновляет логику деклентов
Добавляет поддержку наличия ТОЛЬКО именительного падежа

fixes #777
  • Loading branch information
larentoun authored Nov 27, 2024
1 parent b444f2c commit 116e969
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 73 deletions.
78 changes: 45 additions & 33 deletions modular_bandastation/translations/_translations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ GLOBAL_LIST_EMPTY(ru_eat_verbs)
GLOBAL_LIST_EMPTY(ru_say_verbs)
GLOBAL_LIST_EMPTY(ru_emote_names)
GLOBAL_LIST_EMPTY(ru_emote_messages)
GLOBAL_LIST_EMPTY(ru_reagent_descs)

/datum/modpack/translations
name = "Переводы"
Expand All @@ -12,42 +13,53 @@ GLOBAL_LIST_EMPTY(ru_emote_messages)
/datum/modpack/translations/post_initialize()
// Verbs
var/toml_path = "[PATH_TO_TRANSLATE_DATA]/ru_verbs.toml"
if(!fexists(file(toml_path)))
return
var/list/verbs_toml_list = rustg_read_toml_file(toml_path)
if(fexists(file(toml_path)))
var/list/verbs_toml_list = rustg_read_toml_file(toml_path)

var/list/attack_verbs = verbs_toml_list["attack_verbs"]
for(var/attack_key in attack_verbs)
GLOB.ru_attack_verbs += list("[attack_key]" = attack_verbs[attack_key])
var/list/attack_verbs = verbs_toml_list["attack_verbs"]
for(var/attack_key in attack_verbs)
GLOB.ru_attack_verbs += list("[attack_key]" = attack_verbs[attack_key])

var/list/eat_verbs = verbs_toml_list["eat_verbs"]
for(var/eat_key in eat_verbs)
GLOB.ru_eat_verbs += list("[eat_key]" = eat_verbs[eat_key])
var/list/eat_verbs = verbs_toml_list["eat_verbs"]
for(var/eat_key in eat_verbs)
GLOB.ru_eat_verbs += list("[eat_key]" = eat_verbs[eat_key])

var/list/say_verbs = verbs_toml_list["say_verbs"]
for(var/say_key in say_verbs)
GLOB.ru_say_verbs += list("[say_key]" = say_verbs[say_key])
var/list/say_verbs = verbs_toml_list["say_verbs"]
for(var/say_key in say_verbs)
GLOB.ru_say_verbs += list("[say_key]" = say_verbs[say_key])

// Emotes
var/emote_path = "[PATH_TO_TRANSLATE_DATA]/ru_emotes.toml"
if(!fexists(file(emote_path)))
return
var/list/emotes_toml_list = rustg_read_toml_file(emote_path)

var/list/emote_messages = emotes_toml_list["emote_messages"]
for(var/emote_message_key in emote_messages)
GLOB.ru_emote_messages += list("[emote_message_key]" = emote_messages[emote_message_key])

var/list/emote_names = emotes_toml_list["emote_names"]
for(var/emote_name_key in emote_names)
GLOB.ru_emote_names += list("[emote_name_key]" = emote_names[emote_name_key])

for(var/emote_key as anything in GLOB.emote_list)
var/list/emote_list = GLOB.emote_list[emote_key]
for(var/datum/emote/emote in emote_list)
emote.update_to_ru()
for(var/emote_kb_key as anything in GLOB.keybindings_by_name)
var/datum/keybinding/emote/emote_kb = GLOB.keybindings_by_name[emote_kb_key]
if(!istype(emote_kb))
continue
emote_kb.update_to_ru()
if(fexists(file(emote_path)))
var/list/emotes_toml_list = rustg_read_toml_file(emote_path)

var/list/emote_messages = emotes_toml_list["emote_messages"]
for(var/emote_message_key in emote_messages)
GLOB.ru_emote_messages += list("[emote_message_key]" = emote_messages[emote_message_key])

var/list/emote_names = emotes_toml_list["emote_names"]
for(var/emote_name_key in emote_names)
GLOB.ru_emote_names += list("[emote_name_key]" = emote_names[emote_name_key])

for(var/emote_key as anything in GLOB.emote_list)
var/list/emote_list = GLOB.emote_list[emote_key]
for(var/datum/emote/emote in emote_list)
emote.update_to_ru()
for(var/emote_kb_key as anything in GLOB.keybindings_by_name)
var/datum/keybinding/emote/emote_kb = GLOB.keybindings_by_name[emote_kb_key]
if(!istype(emote_kb))
continue
emote_kb.update_to_ru()

// Reagents desc
var/reagents_path = "[PATH_TO_TRANSLATE_DATA]/ru_reagents.toml"
if(fexists(file(reagents_path)))
var/list/reagents_toml_list = rustg_read_toml_file(reagents_path)

var/list/reagent_descs = reagents_toml_list["reagents_desc"]
for(var/reagent_desc_key in reagent_descs)
GLOB.ru_reagent_descs += list("[reagent_desc_key]" = reagent_descs[reagent_desc_key])

for(var/reagent_key as anything in GLOB.chemical_reagents_list)
var/datum/reagent/reagent = GLOB.chemical_reagents_list[reagent_key]
reagent.update_to_ru()
32 changes: 20 additions & 12 deletions modular_bandastation/translations/code/ru_names/ru_name_base.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ GLOBAL_LIST_EMPTY(ru_names)
/// Необходимо использовать ПЕРЕД изменением var/name, и использовать только этот прок для изменения в рантайме склонений
/atom/ru_names_rename(list/new_list)
if(!length(new_list))
ru_names = null
return
ru_names = new_list
if(new_list["gender"])
Expand All @@ -60,21 +61,28 @@ GLOBAL_LIST_EMPTY(ru_names)
* Процедура выбора правильного падежа для любого предмета, если у него указан словарь «ru_names», примерно такой:
* RU_NAMES_LIST_INIT("jaws of life", "челюсти жизни", "челюстей жизни", "челюстям жизни", "челюсти жизни", "челюстями жизни", "челюстях жизни")
*/
/datum/proc/declent_ru(case_id, list/ru_names_override)
SHOULD_CALL_PARENT(FALSE)
/datum/proc/declent_ru(declent)
CRASH("Unimplemented proc/declent_ru() was used")

/atom/declent_ru(case_id, list/ru_names_override)
var/list/list_to_use = ru_names_override || ru_names
if(length(list_to_use) && list_to_use["base"] == ru_names["base"] && list_to_use[case_id])
return list_to_use[case_id]
if(case_id == "gender")
return
return name
/proc/get_declented_value(list/declented_list, declent, backup_value)
if(declent == "gender")
return declented_list[declent] || backup_value
return declented_list[declent] || declented_list[NOMINATIVE] || backup_value

/atom/declent_ru(declent)
. = name
if(declent == "gender")
. = gender
if(!length(ru_names) || ru_names["base"] != name)
return .
return get_declented_value(ru_names, declent, .)

/// Used for getting initial values, such as for recipies where resulted atom is not yet created.
/proc/declent_ru_initial(target_name, declent, override_backup)
. = override_backup || target_name
if(declent == "gender")
. = NEUTER
var/list/declented_list = ru_names_toml(target_name)
if(length(declented_list) && declented_list[declent])
return declented_list[declent]
return override_backup || target_name
if(!length(declented_list))
return .
return get_declented_value(declented_list, declent, .)
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/datum/material/declent_ru(case_id, list/ru_names_override)
/datum/material
/// List consists of ("name", "именительный", "родительный", "дательный", "винительный", "творительный", "предложный", "gender")
var/list/ru_names

/datum/material/New()
. = ..()
ru_names = ru_names_toml(name)

/datum/material/declent_ru(declent)
. = name
if(!ispath(sheet_type))
CRASH("Sheet type couldn't be declented because it's not a path!")
var/atom/sheet = sheet_type
var/list/list_to_use = ru_names_override || ru_names_toml(name) || ru_names_toml(sheet::name)
if(length(list_to_use) && list_to_use["base"] == name && list_to_use[case_id])
return list_to_use[case_id]
return name
if(declent == "gender")
. = NEUTER
if(!length(ru_names) || ru_names["base"] != name)
return .
return get_declented_value(ru_names, declent, .)
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/datum/orderable_item
var/use_translate = TRUE
/// List consists of ("name", "именительный", "родительный", "дательный", "винительный", "творительный", "предложный", "gender")
var/list/ru_names

/datum/orderable_item/New()
. = ..()
ru_names = ru_names_toml(purchase_path::name)
if(!use_translate)
return
name = capitalize(declent_ru(NOMINATIVE))

/datum/orderable_item/declent_ru(case_id, list/ru_names_override)
/datum/orderable_item/declent_ru(declent)
. = name
if(!ispath(purchase_path))
CRASH("Purchase type couldn't be declented because it's not a path!")
var/list/list_to_use = ru_names_override || ru_names_toml(purchase_path::name)
if(length(list_to_use) && list_to_use["base"] == name && list_to_use[case_id])
return list_to_use[case_id]
return name
if(declent == "gender")
. = NEUTER
if(!length(ru_names))
return .
return get_declented_value(ru_names, declent, .)
23 changes: 10 additions & 13 deletions modular_bandastation/translations/code/ru_names/ru_name_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
/// List consists of ("name", "именительный", "родительный", "дательный", "винительный", "творительный", "предложный", "gender")
var/list/ru_names

/// Необходимо использовать ПЕРЕД изменением var/name, и использовать только этот прок для изменения в рантайме склонений
/datum/reagent/ru_names_rename(list/new_list)
if(!length(new_list))
return
ru_names = new_list
/datum/reagent/proc/update_to_ru()
description = GLOB.ru_reagent_descs[name] || description

/datum/reagent/New()
. = ..()
ru_names_rename(ru_names_toml(LOWER_TEXT(name)))
ru_names = ru_names_toml(name)

/datum/reagent/declent_ru(case_id, list/ru_names_override)
var/list/list_to_use = ru_names_override || ru_names
if(length(list_to_use) && list_to_use["base"] == name && list_to_use[case_id])
return list_to_use[case_id]
if(case_id == "gender")
return
return name
/datum/reagent/declent_ru(declent)
. = name
if(declent == "gender")
. = NEUTER
if(!length(ru_names) || ru_names["base"] != name)
return .
return get_declented_value(ru_names, declent, .)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
["reagents_desc"]
#"Oxygen" = "Описание кислорода"

0 comments on commit 116e969

Please sign in to comment.