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

Update translate from tg again #1633

Merged
merged 3 commits into from
Nov 3, 2024
Merged
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
22 changes: 22 additions & 0 deletions modular_ss220/translations/_translations.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
GLOBAL_LIST_EMPTY(ru_attack_verbs)
GLOBAL_LIST_EMPTY(ru_eat_verbs)
GLOBAL_LIST_EMPTY(ru_say_verbs)

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

/datum/modpack/translations/post_initialize()
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)

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/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])
8 changes: 3 additions & 5 deletions modular_ss220/translations/_translations.dme
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Все изменения следует дублировать на ТГ и наоборот.

#include "_translations.dm"

#include "code/defines.dm"

#include "_translations.dm"

#include "code/pronouns.dm"
#include "code/translate_attack_verb.dm"
#include "code/translate_eat_verb.dm"
#include "code/translate_say.dm"
#include "code/translate_verbs.dm"
#include "code/ru_names/ru_name_base.dm"

#include "code/~undefs.dm"
1 change: 1 addition & 0 deletions modular_ss220/translations/code/defines.dm
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#define RU_NAMES_LENGTH 7 // 6 падежей, 1 base
#define PATH_TO_TRANSLATE_DATA "modular_ss220/translations/code/translate_data"
69 changes: 39 additions & 30 deletions modular_ss220/translations/code/ru_names/ru_name_base.dm
Original file line number Diff line number Diff line change
@@ -1,24 +1,46 @@
GLOBAL_LIST_EMPTY(ru_names)

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

/proc/ru_names_toml(name, prefix, suffix)
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
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]",
"[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]")

/atom/Initialize(mapload, ...)
. = ..()
ru_names_rename(ru_names_toml(name))

/turf/Initialize(mapload)
. = ..()
ru_names_rename(ru_names_toml(name))

/datum/proc/ru_names_rename(list/new_list)
SHOULD_CALL_PARENT(FALSE)
CRASH("Unimplemented proc/ru_names_rename() was used")

/// Необходимо использовать ПЕРЕД изменением var/name, и использовать только этот прок для изменения в рантайме склонений
/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_LIST_INIT(new_list["base"], new_list[NOMINATIVE], new_list[GENITIVE], new_list[DATIVE], new_list[ACCUSATIVE], new_list[INSTRUMENTAL], new_list[PREPOSITIONAL])
ru_names = new_list

/**
* Процедура выбора правильного падежа для любого предмета, если у него указан словарь «ru_names», примерно такой:
Expand All @@ -30,28 +52,15 @@

/atom/declent_ru(case_id, list/ru_names_override)
var/list/list_to_use = ru_names_override || ru_names
if(length(list_to_use))
if(list_to_use[case_id] && list_to_use["base"] == name)
return list_to_use[case_id] || name
if(length(list_to_use) && list_to_use["base"] == ru_names["base"] && list_to_use[case_id])
return list_to_use[case_id]
return name

/// Used for getting initial values, such as for recipies where resulted atom is not yet created.
/proc/declent_ru_initial(atom/target, declent)
/proc/declent_ru_initial(atom/target, declent, override_backup)
if(!istype(target) && !ispath(target, /atom))
CRASH("declent_ru_initial got target that is not an atom or atom's path!")
if(target::ru_name_base != target::name)
return target::name
switch(declent)
if(NOMINATIVE)
return target::ru_name_nominative
if(GENITIVE)
return target::ru_name_genitive
if(DATIVE)
return target::ru_name_dative
if(ACCUSATIVE)
return target::ru_name_accusative
if(INSTRUMENTAL)
return target::ru_name_instrumental
if(PREPOSITIONAL)
return target::ru_name_prepositional
return target::name
return override_backup
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
Loading
Loading