# Path: stampy/i18n.py
# def _(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     language = stampy.language
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[language])
#     return trad.ugettext(string)
# 
# Path: stampy/i18n.py
# def _L(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     loglanguage = stampy.loglanguage
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[loglanguage])
#     return trad.ugettext(string)


import datetime
import logging
import stampy.plugin.alias
import stampy.plugin.config
import stampy.stampy
from prettytable import from_db_cursor
from stampy.i18n import _
from stampy.i18n import _L
    :param word: word to return rank for
    :return:
    """

    logger = logging.getLogger(__name__)
    if word:

        # if word is provided, return the rank value for that word

        if stampy.plugin.alias.getalias(word, gid=gid):
            word = stampy.plugin.alias.getalias(word, gid=gid)

        string = (word, gid)
        sql = "SELECT word,value,date FROM karma WHERE word='%s' and gid='%s';" % string
        cur = stampy.stampy.dbsql(sql)
        value = cur.fetchone()

        try:
            # Get value from SQL query
            value = value[1]

        except:
            # Value didn't exist before, return 0 value
            value = 0
        text = _("`%s` has `%s` karma points.") % (word, value)

    else:
        # if word is not provided, return top 10 words with top karma
        sql = "select word,value,date from karma where gid='%s' ORDER BY value DESC LIMIT 10;" % gid


# Path: stampy/i18n.py
# def _(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     language = stampy.language
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[language])
#     return trad.ugettext(string)
# 
# Path: stampy/i18n.py
# def _L(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     loglanguage = stampy.loglanguage
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[loglanguage])
#     return trad.ugettext(string)


# Path: stampy/plugin/karma.py
import datetime
import logging
import stampy.plugin.alias
import stampy.plugin.config
import stampy.stampy
from prettytable import from_db_cursor
from stampy.i18n import _
from stampy.i18n import _L

    :param word: word to return rank for
    :return:
    """

    logger = logging.getLogger(__name__)
    if word:

        # if word is provided, return the rank value for that word

        if stampy.plugin.alias.getalias(word, gid=gid):
            word = stampy.plugin.alias.getalias(word, gid=gid)

        string = (word, gid)
        sql = "SELECT word,value,date FROM karma WHERE word='%s' and gid='%s';" % string
        cur = stampy.stampy.dbsql(sql)
        value = cur.fetchone()

        try:
            # Get value from SQL query
            value = value[1]

        except:
            # Value didn't exist before, return 0 value
            value = 0
        text = _("`%s` has `%s` karma points.") % (word, value)

    else:
        # if word is not provided, return top 10 words with top karma
        sql = "select word,value,date from karma where gid='%s' ORDER BY value DESC LIMIT 10;" % gid


        text = _("Global rankings:\n")