Configuration
v0.0.1
Mishka Slug 0.0.1 has two application settings: the Gettext backend and the script resolver. Everything else is passed as options to MishkaSlug.slugify/2 or MishkaSlug.Change, so every call site shows what it uses.
Settings
| Key | Value | Default | What it does |
|---|---|---|---|
:gettext_backend | A module that uses Gettext.Backend | MishkaSlug.Gettext | Where MishkaSlug.Messages looks up the texts, in the mishka_slug domain. The library backend ships English. |
:script_resolver | {module, function, args} | none | Gives the scripts of each :locales code instead of the built-in table. The :script_resolver option of a call wins. |
config :mishka_slug, :gettext_backend, MyAppWeb.Gettext
config :mishka_slug, :script_resolver, {MyApp.LocaleScripts, :scripts, []}Set both in config/config.exs or config/runtime.exs. MishkaSlug.Messages.gettext_backend/0 reads the backend at run time. Do not put other slug options in application config.
Messages
The texts of the mishka_slug Gettext domain:
| Text | Used for |
|---|---|
has no letters or digits to make a slug from | :empty |
uses letters or digits that the site languages do not allow in a slug | :no_allowed_script |
mixes writing systems inside one word | :mixed_scripts |
is not valid UTF-8 text | :invalid_utf8 |
uses a site language the slug does not know: %{code} | {:unknown_locale, code} |
is not a string value | A value that is not a string, in MishkaSlug.Change |
The template is priv/gettext/mishka_slug.pot in the package. See Handle errors and translate messages.
Packages
Mishka Slug 0.0.1 needs Elixir 1.20 or later and is licensed under Apache-2.0. It depends on guarded_struct and gettext. ash is optional and only MishkaSlug.Change uses it.
Usage rules for coding agents
The package ships usage_rules files (usage-rules.md, and usage-rules/ash.md and usage-rules/configuration.md) so a coding agent knows the options, the return shapes and the do's and don'ts. Add usage_rules as a dev dependency, list mishka_slug with its sub rules in project/0, and run mix usage_rules.sync:
{:usage_rules, "~> 1.2", only: :dev}
usage_rules: [
file: "CLAUDE.md",
usage_rules: [{:mishka_slug, sub_rules: ["ash", "configuration"]}]
]Links
- Mishka Slug on Hex and on HexDocs.
- Source on GitHub, and issues.
- Mishka CMS, which uses Mishka Slug for the addresses of its posts and pages.