Get Started with Translations
Installation
# you can use a Conda environment
pip install --extra-index-url "https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/" python-dotenv gllm-intl# you can use a Conda environment
pip install --extra-index-url "https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/" python-dotenv gllm-intlFOR /F "tokens=*" %T IN ('gcloud auth print-access-token') DO pip install --extra-index-url "https://oauth2accesstoken:%T@glsdk.gdplabs.id/gen-ai-internal/simple/" python-dotenv gllm-intlQuickstart
1
Prepare your project
<project-name>/
βββ locales/
β βββ en_US/LC_MESSAGES/messages.mo # English (US) locale
β βββ id_ID/LC_MESSAGES/messages.mo # Indonesian locale
β βββ [other locales...]
βββ main.pyWhat's next?
provider.get_translation("greeting", locale="en_US")@app.before_request def setup_locale(): set_locale(request.headers.get("Accept-Language", "en_US"))with locale_context("id_ID"): print(_("greeting")) # "Halo"
Last updated
Was this helpful?