User-friendly translations manager for Elixir/Phoenix projects.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
About The Project
TODO
Getting Started
Prerequisites
- Elixir/Phoenix project
- Database setup
Installation
The package can be installed
by adding kanta to your list of dependencies in mix.exs:
def deps do
[
{:kanta, "~> 0.1.0"},
{:gettext, git: "git@github.com:bamorim/gettext.git", branch: "runtime-gettext"}
]
end
The dependency on this specific gettext version is because this library depends on an in-progress feature, to be included in a future release of gettext (see discussion in elixir-gettext/gettext#280 and pull request elixir-gettext/gettext#305). As of March 2023, this has been approved by an Elixir core team member, so we are eagerly awaiting for it being merged upstream.
Add configuration
Add to config/config.exs file:
# config/config.exs
config :kanta,
ecto_repo: MyApp.Repo,
project_root: File.cwd!()
Ecto repo is used for translations persistency.
Create migration
Create migration with
mix ecto.gen.migration add_kanta_translations_table
Open the generated migration file and set up up and down functions:
defmodule MyApp.Repo.Migrations.AddKantaTranslationsTable do
use Ecto.Migration
def up do
Kanta.Migrations.up()
end
def down do
Kanta.Migrations.down()
end
end
And run
mix ecto.migrate
Adjust Gettext module
Add Kanta Repo as a default translation repository inside your Gettext module.
use Gettext, ..., repo: Kanta.Gettext.Repo
Setup Kanta UI
Inside your router.ex file forward desired path to the KantaWeb.Router.
scope "/" do
pipe_through :browser
forward "/kanta", KantaWeb.Router
end
Usage
- Start Phoenix server and visit
localhost:4000/kanta(or otherpath you've set in the router.ex file). - From there you can check and modify your translations from already existing .po files.
TODO
Roadmap
- Support plural translations
- Normalize database
- Add documentation and typespecs
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. We prefer gitflow and Conventional ommits style but we don't require that. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'feat: Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE.txt for more information.
Contact
Michał Buszkiewicz - michal@curiosum.com
Krzysztof Janiec - krzysztof.janiec@curiosum.com
Artur Ziętkiewicz - artur.zietkiewicz@curiosum.com