-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
93 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from .base import LanguageMeta # noqa | ||
from . import ( | ||
ru, | ||
) | ||
|
||
__all__ = ("ru",) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import random | ||
import re | ||
|
||
|
||
class LanguageMeta(type): | ||
code = "langcode" | ||
highlights = [ | ||
"a new wiki article is just a click away:", | ||
"does that seem promising?", | ||
"please take a look", | ||
"there's a change waiting for reviews to happen:", | ||
] | ||
|
||
__languages = {} | ||
|
||
def __new__(mcs, name, bases, attrs): | ||
cls = super().__new__(mcs, name, bases, attrs) | ||
if name != "Language": | ||
assert cls.code not in mcs.__languages, f"there's already a language class with the code {cls.code!r}" | ||
mcs.__languages[cls.code] = cls | ||
return cls | ||
|
||
@property | ||
def title_regex(mcs): | ||
if not hasattr(mcs, "__regex"): | ||
mcs.__regex = re.compile(r"^\[(\w+.?)?{}(.+)?\]".format(mcs.code.upper())) | ||
return mcs.__regex | ||
|
||
@property | ||
def random_highlight(mcs): | ||
return random.choice(mcs.HIGHLIGHTS) | ||
|
||
@classmethod | ||
def get(mcs, langcode): | ||
return mcs.__languages[langcode] | ||
|
||
|
||
class Language(metaclass=LanguageMeta): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from librarian.discord.languages import base | ||
|
||
|
||
class Russian(base.Language): | ||
code = "ru" | ||
highlights = [ | ||
"a new wiki article is just a click away:", | ||
u"время исправлять чужие ошибки:", | ||
u"вышла новая книга Владимира Сорокина:", | ||
u"на GitHub опять что-то перевели:", | ||
u"хороших выходных:", | ||
u"объясняем на карточках вместе с Медузой:", | ||
u"вот ещё кое-что:", | ||
u"пожалуйста, взгляните:", | ||
u"доставайте красные карандаши:", | ||
u"если некуда девать свободное время:", | ||
u"новый пулл-реквест на небосклоне:", | ||
u"у нас на один перевод больше:", | ||
u"произошло что-то интересное:", | ||
u"у вас одно новое сообщение:", | ||
u"перевод? перевод!", | ||
u"вам письмо от неанонимного доброжелателя:", | ||
u"здесь могла быть ваша реклама:", | ||
u"нужна помощь:", | ||
'`wiki.by_language("russian").inflight_translations += 1`', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters