paulsabou
Gettext_llm - Elixir Gettext LLM based translation library
gettext_llm
What does it do?
The gettext_llm library allows you to translate all Gettext PO folders/files in your project using any LLM endpoint supported by langchain. The library provides several mix tasks that can be run directly in your Elixir/Phoenix project from the command line (ie. locally on the dev machine) or part of a CI/CD pipeline.
Translating from one language to another requires the translator to be accurate and to maintain a consistent tone/persona and style. Scaling these to multiple languages is challenging. Automated translation with LLM’s provide a “good enough” alternative in many use cases.
gettext_llm provides configurable tone/persona and style. This allows you to “shape” your resulting translations into something that is compatible with your app audience & brand.
How to add it to your Elixir/Phoenix project?
1. Add it as a dev dependency in your mix.exs
def deps do
[
{:gettext_llm, "0.1.9", only: [:dev, :test]}
]
end
2. Add a few lines in your config.exs
config :gettext_llm, GettextLLM,
# ignored_languages: ["en"] <--- Optional but good to skip translating your reference language
persona:
"You are translating messages for a website that connects people needing help with people that can provide help. You will provide translation that is casual but respectful and uses plain language.",
style:
"Casual but respectul. Uses plain plain language that can be understood by all age groups and demographics.",
endpoint: LangChain.ChatModels.ChatOpenAI,
endpoint_model: "gpt-4",
endpoint_temperature: 0,
endpoint_config: %{
"openai_key" =>
"<YOUR_OPENAI_KEY>",
"openai_org_id" => "<YOUR_ORG_ID>"
}
3. Run the task
mix gettext_llm.translate translate
Key Features
- Built on top of langchain so you can use different LLM endpoints
- No runtime dependencies (it’s just a mix task)
- Configurable tone/persona and style
Links:
Popular in Announcing
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








