# Path: KPC/classes.py
# class Error:
#     '''An individual error from a check against an entry. One check
#     usually returns list of errors or empty list if there's no error.
#     '''
#     SUCCESS = 0
#     DEPRECATED = 1
#     WARNING = 2
#     ERROR = 3
# 
#     def __init__(self, message):
#         self.pos = 0
#         self.level = Error.ERROR
#         self.message = message
# 
# class BaseCheck:
#     '''Base class to check an entry from PO files. Subclasses should
#     implement check() function. check() returns list of errors if any.
#     '''
#     def _get_context(self, entry):
#         if not hasattr(self, 'get_context'):
#             return {}
#         fields = {}
#         # parse msgstr
#         for line in entry.msgstr.split('\n'):
#             try:
#                 k, v = line.split(': ', 1)
#                 fields[k] = v
#             except ValueError:
#                 pass
#         return self.get_context(entry, fields)
# 
#     def _check(self, entry, context):
#         return self.check(entry, context)


from KPC.classes import Error, BaseCheck
    ('template', '서식', '틀'),
    ('thread', '스레드', '쓰레드'),
    ('update', '업데이트', '갱신'),
    ('username', '사용자 이름', '사용자명'),
    ('version', '버전', '버젼'),
    ('version', '버전', '판번호'),
    ('vimeo', '비미오', '비메오'),
    ('youtube', '유튜브', '유투브'),
    ('windows', '윈도우', '윈도우즈'),
]


class WordGuideCheck(BaseCheck):
    errstr = '%s: \"%s\"은(는) \"%s\"(이)라고 번역하길 제안합니다'

    def check(self, entry, context):
        msgid = entry.msgid
        msgstr = entry.msgstr
        errors = []
        msgid_l = msgid.replace('_', '').replace('&', '').lower()
        for (id, right, wrong) in data:
            if (wrong not in msgstr) or (id not in msgid_l):
                continue
            if (right not in wrong) and (right in msgstr):
                continue
            errors.append(Error(self.errstr % (wrong, id, right.strip())))
        return errors

name = 'terminology/word-guide'
description = '바람직하지 않은 번역 용어를 검사합니다'

# Path: KPC/classes.py
# class Error:
#     '''An individual error from a check against an entry. One check
#     usually returns list of errors or empty list if there's no error.
#     '''
#     SUCCESS = 0
#     DEPRECATED = 1
#     WARNING = 2
#     ERROR = 3
# 
#     def __init__(self, message):
#         self.pos = 0
#         self.level = Error.ERROR
#         self.message = message
# 
# class BaseCheck:
#     '''Base class to check an entry from PO files. Subclasses should
#     implement check() function. check() returns list of errors if any.
#     '''
#     def _get_context(self, entry):
#         if not hasattr(self, 'get_context'):
#             return {}
#         fields = {}
#         # parse msgstr
#         for line in entry.msgstr.split('\n'):
#             try:
#                 k, v = line.split(': ', 1)
#                 fields[k] = v
#             except ValueError:
#                 pass
#         return self.get_context(entry, fields)
# 
#     def _check(self, entry, context):
#         return self.check(entry, context)


# Path: KPC/checks/terminology/word-guide.py
from KPC.classes import Error, BaseCheck

    ('template', '서식', '틀'),
    ('thread', '스레드', '쓰레드'),
    ('update', '업데이트', '갱신'),
    ('username', '사용자 이름', '사용자명'),
    ('version', '버전', '버젼'),
    ('version', '버전', '판번호'),
    ('vimeo', '비미오', '비메오'),
    ('youtube', '유튜브', '유투브'),
    ('windows', '윈도우', '윈도우즈'),
]


class WordGuideCheck(BaseCheck):
    errstr = '%s: \"%s\"은(는) \"%s\"(이)라고 번역하길 제안합니다'

    def check(self, entry, context):
        msgid = entry.msgid
        msgstr = entry.msgstr
        errors = []
        msgid_l = msgid.replace('_', '').replace('&', '').lower()
        for (id, right, wrong) in data:
            if (wrong not in msgstr) or (id not in msgid_l):
                continue
            if (right not in wrong) and (right in msgstr):
                continue
            errors.append(Error(self.errstr % (wrong, id, right.strip())))
        return errors

name = 'terminology/word-guide'
description = '바람직하지 않은 번역 용어를 검사합니다'

checker = WordGuideCheck()