-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from mogproject/topic-i18n-#15
implement i18n (en or ja)
- Loading branch information
Showing
5 changed files
with
70 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.0.5' | ||
__version__ = '0.0.6' |
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 |
---|---|---|
@@ -1 +1,18 @@ | ||
from messages_ja import * | ||
import os | ||
import locale | ||
|
||
|
||
def __get_locale(): | ||
# environment LANG is the first priority | ||
lang = os.environ.get('LANG') | ||
if lang: | ||
return lang.lower() | ||
return locale.getdefaultlocale()[0].lower() | ||
|
||
|
||
__locale = __get_locale() | ||
|
||
if __locale.startswith('ja_'): | ||
from messages_ja import * | ||
else: | ||
from messages_en import * |
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,30 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
EMAIL_ENCODING = 'utf-8' | ||
|
||
MSG_DEBUG = u"DEBUG" | ||
MSG_INFO = u"INFO" | ||
MSG_WARN = u"WARN" | ||
MSG_ERROR = u"ERROR" | ||
MSG_CRITICAL = u"CRITICAL" | ||
|
||
MSG_PROC_NOT_RUNNING = u'not running' | ||
MSG_PROC_RUNNING = u'%(count)d process(es) are running' | ||
MSG_PROC_STATUS_FORMAT = u'[%(level)s] %(name)s: %(count)s (not "%(condition)s")' | ||
MSG_PROC_ALERT_TITLE = u'Detected Process Abnormality' | ||
MSG_PROC_ALERT = u'Detected the following process abnormality on server \'%(server_id)s\'.\n\n%(result)s\n\n==' | ||
|
||
MSG_LOG_SUMMARY = u'[%(tag)s]: %(count)d messages' | ||
MSG_LOG_SNIP = u'(snip)' | ||
MSG_LOG_ALERT_TITLE = u'Detected Error Messages' | ||
MSG_LOG_ALERT = u'Detected the following errors on server \'%(server_id)s\'.\n\n%(result)s\n==' | ||
MSG_LOG_ALERT_PENDING_TITLE = u'Possible Retention of Log Watcher' | ||
MSG_LOG_ALERT_PENDING = u"""Detected the possible retention of Log Watcher on server \'%(server_id)s\'.\n | ||
There exist multiple files which matches the pattern %(pattern)s.\n\n%(paths)s\n | ||
Please check the state of the files, then restart Fluentd or other applications if needed.""" | ||
|
||
MSG_SSH_STATUS_FORMAT = u'[%(name)s](%(user)s@%(host)s:%(port)d): %(msg)s' | ||
MSG_SSH_ALERT_TITLE = u'Detected SSH Connection Error' | ||
MSG_SSH_ALERT = u'Failed to connect to the following servers using SSH from \'%(server_id)s\'.\n\n%(result)s\n\n==' | ||
|
||
MSG_SUBJECT_FORMAT = u'【%(level)s】[%(group_id)s:%(server_id)s] %(title)s (%(start_time)s)' |
Empty file.
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,21 @@ | ||
import unittest | ||
import os | ||
|
||
|
||
class TestI18N(unittest.TestCase): | ||
def get_email_encoding(self): | ||
import easy_alert | ||
|
||
reload(easy_alert.i18n) | ||
return easy_alert.i18n.EMAIL_ENCODING | ||
|
||
def test_lang_detection_jp(self): | ||
os.environ['LANG'] = 'ja_JP.UTF-8' | ||
self.assertEqual(self.get_email_encoding(), 'iso-2022-jp') | ||
|
||
def test_lang_detection_en(self): | ||
os.environ['LANG'] = 'C' | ||
self.assertEqual(self.get_email_encoding(), 'utf-8') | ||
|
||
del os.environ['LANG'] | ||
self.assertNotEqual(self.get_email_encoding(), None) # the result depends on the system |