Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
talyguryn committed May 24, 2017
1 parent 833635e commit 5922864
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
19 changes: 19 additions & 0 deletions build_i18n.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

## Auto update with entr. (TODO remove these strings)
# ls i18n/ru/LC_MESSAGES/main.po | entr -c ./build_i18n.sh


dirSource="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

dir="$dirSource/i18n"

array=( $(find $dir -name "*.po") )

for poFileName in ${array[@]}
do
moFileName="${poFileName%*.po}.mo"

msgfmt $poFileName -o $moFileName
echo "Created file $moFileName"
done
8 changes: 7 additions & 1 deletion codexbot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import importlib
import logging
import os
import gettext

from codexbot.lib.db import Db
from codexbot.lib.logging import Logging
Expand All @@ -16,6 +17,7 @@ def __init__(self):
self.services = {}

self.logging = Logging()
self.init_i18n()
self.event_loop = asyncio.get_event_loop()
self.init_db()
self.init_broker()
Expand All @@ -24,6 +26,10 @@ def __init__(self):
self.init_queue()
self.server.start()

def init_i18n(self):
gettext.translation('main', 'i18n', ['ru']).install()
logging.debug("Initiate i18n.")

def init_queue(self):
logging.debug("Initiate queue and loop.")
self.broker.start()
Expand All @@ -39,7 +45,7 @@ def init_db(self):
Initialize self.db object with 'default' database name
:return:
"""
logging.debug("Initiate DB")
logging.debug("Initiate DB.")
self.db = Db(DB['name'], DB['host'], DB['port'])

def init_services(self):
Expand Down
Binary file added i18n/ru/LC_MESSAGES/main.mo
Binary file not shown.
4 changes: 4 additions & 0 deletions i18n/ru/LC_MESSAGES/main.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from codexbot.core import Core


core = Core()

0 comments on commit 5922864

Please sign in to comment.