Skip to content

Commit

Permalink
Add failsafe for ru_names (#517)
Browse files Browse the repository at this point in the history
## About The Pull Request
Добавление фейл-сейфа, если оригинальное имя не совпадает с тем, что мы
переводили.
Нужно добавлять на ключ "base" оригинальное название.

Пример с 
`var/list/ru_names = RU_NAMES_LIST_INIT("jaws of life", "именительный",
"родительный", "дательный", "винительный", "творительный",
"предложный")`


![Screenshot_1](https://github.com/user-attachments/assets/b27adb3e-6657-4710-9734-ae59ff8db264)
  • Loading branch information
larentoun authored Oct 6, 2024
1 parent 9ad4488 commit 242a575
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions code/__DEFINES/bandastation/pronouns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

// Падежи русского языка
/// Именительный: Кто это? Клоун и ассистуха.
#define NOMINATIVE 1
#define NOMINATIVE "именительный"
/// Родительный: Откусить кусок от кого? От клоуна и ассистухи.
#define GENITIVE 2
#define GENITIVE "родительный"
/// Дательный: Дать полный доступ кому? Клоуну и ассистухе.
#define DATIVE 3
#define DATIVE "дательный"
/// Винительный: Обвинить кого? Клоуна и ассистуху.
#define ACCUSATIVE 4
#define ACCUSATIVE "винительный"
/// Творительный: Возить по полу кем? Клоуном и ассистухой.
#define INSTRUMENTAL 5
#define INSTRUMENTAL "творительный"
/// Предложный: Прохладная история о ком? О клоуне и об ассистухе.
#define PREPOSITIONAL 6
#define PREPOSITIONAL "предложный"

/// Макрос для упрощения создания листа падежей для объекта
#define RU_NAMES_LIST_INIT(nominative, genitive, dative, accusative, instrumental, prepositional) (list(NOMINATIVE = nominative, GENITIVE = genitive, DATIVE = dative, ACCUSATIVE = accusative, INSTRUMENTAL = instrumental, PREPOSITIONAL = prepositional))
#define RU_NAMES_LIST_INIT(base, nominative, genitive, dative, accusative, instrumental, prepositional) (list("base" = base, NOMINATIVE = nominative, GENITIVE = genitive, DATIVE = dative, ACCUSATIVE = accusative, INSTRUMENTAL = instrumental, PREPOSITIONAL = prepositional))
7 changes: 4 additions & 3 deletions modular_bandastation/translations/code/pronouns.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/atom
// code\__DEFINES\bandastation\pronouns.dm for more info
/// ru_names = RU_NAMES_LIST_INIT("именительный", "родительный", "дательный", "винительный", "творительный", "предложный")
/// ru_names = RU_NAMES_LIST_INIT("jaws of life", "именительный", "родительный", "дательный", "винительный", "творительный", "предложный")
var/list/ru_names

/**
* Процедура выбора правильного падежа для любого предмета, если у него указан словарь «ru_names», примерно такой:
* ru_names = RU_NAMES_LIST_INIT("челюсти жизни", "челюстей жизни", "челюстям жизни","челюсти жизни", "челюстями жизни", "челюстях жизни")
* ru_names = RU_NAMES_LIST_INIT("jaws of life", "челюсти жизни", "челюстей жизни", "челюстям жизни","челюсти жизни", "челюстями жизни", "челюстях жизни")
*/
/datum/proc/declent_ru(case_id, list/ru_names_override)
var/list/list_to_use = ru_names_override
Expand All @@ -16,7 +16,8 @@
/atom/declent_ru(case_id, list/ru_names_override)
var/list/list_to_use = ru_names_override || ru_names
if(length(list_to_use))
return list_to_use[case_id] || name
if(list_to_use[case_id] && list_to_use["base"] == name)
return list_to_use[case_id] || name
return name

/// Склонения, например "секунда", "секунды", "секунд".
Expand Down

0 comments on commit 242a575

Please sign in to comment.