Skip to content

Instantly share code, notes, and snippets.

@tomotaka
Last active December 22, 2015 19:29
Show Gist options
  • Save tomotaka/6519987 to your computer and use it in GitHub Desktop.
Save tomotaka/6519987 to your computer and use it in GitHub Desktop.
use pyramid i18n(localizer) out side of web framework(in my case, it's test)
from pyramid.i18n import make_localizer, TranslationString
dir = '/your/locale/dir'
directories = (dir,)
txt_want_to_translate = TranslationString('hoge_moge')
# txt_want_to_translate = TranslationString('hoge_moge', domain='some_domain')
locale = 'ja'
localizer = make_localizer(locale, directories)
transltaed_str = localizer.translate(txt_want_to_translate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment