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

add: ru-translation procs from wiki #717

Closed
wants to merge 3 commits into from
Closed
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
14 changes: 14 additions & 0 deletions code/__DEFINES/translation.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Grammatical cases

/// Именительный: кто это? Клоун и ассистуха
#define NOMINATIVE 1
/// Родительный: откусить кусок от кого? От клоуна и ассистухи
#define GENITIVE 2
/// Дательный: дать полный доступ кому? Клоуну и ассистухе
#define DATIVE 3
/// Винительный: обвинить кого? Клоуна и ассистуху
#define ACCUSATIVE 4
/// Творительный: возить по полу кем? Клоуном и ассистухой
#define INSTRUMENTAL 5
/// Предложный: прохладная история о ком? О клоуне и об ассистухе
#define PREPOSITIONAL 6
mattgroy marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions modular_ss220/modular_ss220.dme
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include "sm_space_drop/sm_space_drop.dme"
#include "text_to_speech/_tts.dme"
#include "title_screen/_title_screen.dme"
#include "translation/_translation.dme"
#include "verbs/_verbs.dme"
#include "whitelist/_whitelist.dme"
#include "outfits/_outfits.dme"
Expand Down
4 changes: 4 additions & 0 deletions modular_ss220/translation/_translation.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/datum/modpack/translation
name = "RU Перевод"
desc = "Вспомогательные методы и оверрайды для перевода игры."
author = "mattgroy"
3 changes: 3 additions & 0 deletions modular_ss220/translation/_translation.dme
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "_translation.dm"
#include "code/atoms.dm"
#include "code/globals.dm"
26 changes: 26 additions & 0 deletions modular_ss220/translation/code/atoms.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/atom
/**
* List of an atom's name in different cases.
*
* Example:
* name_cases = list("челюсти жизни", "челюстей жизни", "челюстям жизни", "челюсти жизни", "челюстями жизни", "челюстях жизни")
* name_cases = list(NOMINATIVE = "челюсти жизни", GENITIVE = "челюстей жизни", DATIVE = "челюстям жизни", ACCUSATIVE = "челюсти жизни", INSTRUMENTAL = "челюстями жизни", PREPOSITIONAL = "челюстях жизни")
*/
var/list/name_cases

/**
* Returns an atom's name in the selected grammatical case.
*
* Different cases of the name are defined in [name_cases][/atom/var/list/name_cases].
* If selected case is not defined, proc tries to get a name in a `NOMINATIVE` case, otherwise returns an atom's original `name`.
*
* Arguments:
* * case - NOMINATIVE, GENITIVE, DATIVE, ACCUSATIVE, INSTRUMENTAL, PREPOSITIONAL
* * name_cases_override - optional list of object names in different cases
*/
/atom/proc/declension_case(case, list/name_cases_override)
var/list/case_list = name_cases_override || name_cases
if(length(case_list) && isnum(case))
var/case_index = InRange(case, 1, length(case_list)) ? case : NOMINATIVE
return case_list[case_index] || name
return name
33 changes: 33 additions & 0 deletions modular_ss220/translation/code/globals.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Returns the correct word based on an inputted `gender`.
*/
/proc/genderize(gender, male_word, female_word, neuter_word, multiple_word)
switch(gender)
if(MALE)
. = male_word
if(FEMALE)
. = female_word
if(PLURAL)
. = multiple_word
else
. = neuter_word

/**
* Returns the correct word based on an inputted `gender` - whether plural or singular (any other gender).
*/
/proc/pluralize(gender, singular_word, plural_word)
return gender == PLURAL ? plural_word : singular_word

/**
* Returns the correct word based on a preceding `number`.
*
* Refers to a "grammatical number" feature of nouns. Implements Russian grammar rules of declension with numerals.
*/
/proc/declension_number(number, singular_word, dual_word, plural_word)
if(!isnum(number) || round(number) != number)
return dual_word // fractional numbers
if(((number % 10) == 1) && ((number % 100) != 11)) // 1, not 11
return singular_word
if(((number % 10) in 2 to 4) && !((number % 100) in 12 to 14)) // 2, 3, 4, not 12, 13, 14
return dual_word
return plural_word // 5, 6, 7, 8, 9, 0
1 change: 1 addition & 0 deletions paradise.dme
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
#include "code\__DEFINES\tgs.dm"
#include "code\__DEFINES\tgui_defines.dm"
#include "code\__DEFINES\tools_defines.dm"
#include "code\__DEFINES\translation.dm"
mattgroy marked this conversation as resolved.
Show resolved Hide resolved
#include "code\__DEFINES\turfs.dm"
#include "code\__DEFINES\typeids.dm"
#include "code\__DEFINES\uplinks_defines.dm"
Expand Down
Loading