import gettext


def get_i18n_content_by_lang(fmt, local, lang, **kw):
    """
    Get another language string according to key string.

        reference
        - `Common Message Property <https://docs.python.org/2/library/gettext.html>`_

    :param fmt: Multilingual key string. like _('This is a translatable string.')
    :param local: Domain corresponding to "fmt".
    :param lang: Language. ['en'|'ko'|'ja']
    :param kw: Named variable parameter list.
    :return: a string.
    """
    local_text = gettext.translation(local, 'locales', [lang])

    if len(kw) > 0:
        content = local_text.gettext(fmt).format(**kw)
    else:
        content = local_text.gettext(fmt)
    return content