Skip to content

Commit

Permalink
Merge branch 'master' into translate
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 27, 2024
2 parents 49db665 + e19a553 commit ee29499
Show file tree
Hide file tree
Showing 10 changed files with 1,684 additions and 353 deletions.
14 changes: 0 additions & 14 deletions code/__DEFINES/modular_ss220/pronouns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,3 @@
#define INSTRUMENTAL "творительный"
/// Предложный: Прохладная история о ком? О клоуне и об ассистухе.
#define PREPOSITIONAL "предложный"

/// Макрос для упрощения создания листа падежей для объекта
#define RU_NAMES_LIST(base, nominative, genitive, dative, accusative, instrumental, prepositional) (list("base" = base, NOMINATIVE = nominative, GENITIVE = genitive, DATIVE = dative, ACCUSATIVE = accusative, INSTRUMENTAL = instrumental, PREPOSITIONAL = prepositional))

/// Макрос для добавления значений для переменных
#define RU_NAMES_LIST_INIT(base, nominative, genitive, dative, accusative, instrumental, prepositional)\
ru_names = RU_NAMES_LIST(base, nominative, genitive, dative, accusative, instrumental, prepositional);\
ru_name_base = base;\
ru_name_nominative = nominative;\
ru_name_genitive = genitive;\
ru_name_dative = dative;\
ru_name_accusative = accusative;\
ru_name_instrumental = instrumental;\
ru_name_prepositional = prepositional
24 changes: 24 additions & 0 deletions modular_ss220/translations/_translations.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
GLOBAL_LIST_EMPTY(ru_attack_verbs)
GLOBAL_LIST_EMPTY(ru_eat_verbs)
GLOBAL_LIST_EMPTY(ru_say_verbs)
GLOBAL_LIST_EMPTY(ru_emote_names)
GLOBAL_LIST_EMPTY(ru_emote_messages)

/datum/modpack/translations
name = "Переводы"
desc = "Добавляет переводы"
author = "Vallat, Larentoun, dj-34"

/datum/modpack/translations/post_initialize()
// Verbs
var/toml_path = "[PATH_TO_TRANSLATE_DATA]/ru_verbs.toml"
if(!fexists(file(toml_path)))
return
Expand All @@ -24,3 +27,24 @@ GLOBAL_LIST_EMPTY(ru_say_verbs)
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/datum/keybinding/emote/emote_kb in GLOB.keybindings)
emote_kb.update_to_ru()
1 change: 1 addition & 0 deletions modular_ss220/translations/_translations.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "_translations.dm"

#include "code/pronouns.dm"
#include "code/translate_emotes.dm"
#include "code/translate_verbs.dm"
#include "code/ru_names/ru_name_base.dm"

Expand Down
1 change: 0 additions & 1 deletion modular_ss220/translations/code/defines.dm
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#define RU_NAMES_LENGTH 7 // 6 падежей, 1 base
#define PATH_TO_TRANSLATE_DATA "modular_ss220/translations/code/translate_data"
29 changes: 21 additions & 8 deletions modular_ss220/translations/code/ru_names/ru_name_base.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,34 @@ GLOBAL_LIST_EMPTY(ru_names)

/atom
// code\__DEFINES\bandastation\pronouns.dm for more info
/// List consists of ("name", "именительный", "родительный", "дательный", "винительный", "творительный", "предложный")
/// List consists of ("name", "именительный", "родительный", "дательный", "винительный", "творительный", "предложный", "gender")
var/list/ru_names

/proc/ru_names_toml(name, prefix, suffix)
/// Хелпер для создания склонений
/proc/ru_names_list(base, nominative, genitive, dative, accusative, instrumental, prepositional, gender)
if(!base || !nominative || !genitive || !dative || !accusative || !instrumental || !prepositional)
CRASH("ru_names_list() received incomplete declent list!")
return list("base" = base, NOMINATIVE = nominative, GENITIVE = genitive, DATIVE = dative, ACCUSATIVE = accusative, INSTRUMENTAL = instrumental, PREPOSITIONAL = prepositional, "gender" = gender)

/proc/ru_names_toml(name, prefix, suffix, override_base)
. = list()
if(!length(GLOB.ru_names))
var/toml_path = "[PATH_TO_TRANSLATE_DATA]/ru_names.toml"
if(!fexists(file(toml_path)))
GLOB.ru_names = list("ERROR" = "File not found!")
return
return .
GLOB.ru_names = rustg_read_toml_file("[PATH_TO_TRANSLATE_DATA]/ru_names.toml")
if(GLOB.ru_names[name])
return RU_NAMES_LIST(
"[prefix][name][suffix]",
var/base = override_base || "[prefix][name][suffix]"
. = ru_names_list(
base,
"[prefix][GLOB.ru_names[name]["nominative"]][suffix]",
"[prefix][GLOB.ru_names[name]["genitive"]][suffix]",
"[prefix][GLOB.ru_names[name]["dative"]][suffix]",
"[prefix][GLOB.ru_names[name]["accusative"]][suffix]",
"[prefix][GLOB.ru_names[name]["instrumental"]][suffix]",
"[prefix][GLOB.ru_names[name]["prepositional"]][suffix]")
"[prefix][GLOB.ru_names[name]["prepositional"]][suffix]",
gender = "[GLOB.ru_names[name]["gender"]]",)

/atom/Initialize(mapload, ...)
. = ..()
Expand All @@ -38,9 +47,11 @@ GLOBAL_LIST_EMPTY(ru_names)
/atom/ru_names_rename(list/new_list)
if(!length(new_list))
return
if(length(new_list) != RU_NAMES_LENGTH)
CRASH("proc/ru_names_rename() received incorrect list!")
ru_names = new_list
if(new_list["gender"])
gender = new_list["gender"]
else
gender = src::gender

/**
* Процедура выбора правильного падежа для любого предмета, если у него указан словарь «ru_names», примерно такой:
Expand All @@ -54,6 +65,8 @@ GLOBAL_LIST_EMPTY(ru_names)
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

/// Used for getting initial values, such as for recipies where resulted atom is not yet created.
Expand Down
Loading

0 comments on commit ee29499

Please sign in to comment.