<commit_before># -*- coding: utf-8 -*-

import os
from gettext import translation

from lektor.pluginsystem import Plugin
from markupsafe import Markup


LOCALES_DIR = os.path.join(
    os.path.dirname(os.path.abspath(__file__)),
    'locales'
)


class Translator(object):

    def configure(self, locale):
        self.lang = translation(
            'messages', localedir=LOCALES_DIR, languages=[locale])
        self.lang.install()

    def translate(self, string):
        return self.lang.gettext(string)


class __proxy__(object):

    def __init__(self, string, translator):
        self.translator = translator
        self.string = string

    def __repr__(self):
        return self.translator.translate(self.string)<commit_msg>add py2 compatiblity<commit_after># -*- coding: utf-8 -*-

from __future__ import unicode_literals

import os
import sys
from gettext import translation

from lektor.pluginsystem import Plugin
from markupsafe import Markup

PY3 = sys.version_info > (3,)

LOCALES_DIR = os.path.join(
    os.path.dirname(os.path.abspath(__file__)),
    'locales'
)


class Translator(object):

    def configure(self, locale):
        self.lang = translation(
            'messages', localedir=LOCALES_DIR, languages=[locale])
        self.lang.install()

    def translate(self, string):
        if PY3:
            return self.lang.gettext(string)
        else:
            return self.lang.ugettext(string)


class __proxy__(object):

    def __init__(self, string, translator):
        self.translator = translator
        self.string = string

    def __repr__(self):
        return self.translator.translate(self.string)
{'fraction_non_alphanumeric': 0.10443230115361263, 'fraction_numerical': 0.0036429872495446266, 'mean_word_length': 3.0691358024691358, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1044802', 'n_tokens_mistral': 510, 'n_tokens_neox': 485, 'n_words': 117}