Configuration

v0.0.3

Mishka Slug 0.0.3 has three application settings: the Gettext backend, the script resolver and the change presets. Everything else is passed as options to MishkaSlug.slugify/2 or MishkaSlug.Change, so every call site shows what it uses.

Settings

KeyValueDefaultWhat it does
:gettext_backendA module that uses Gettext.BackendMishkaSlug.GettextWhere MishkaSlug.Messages looks up the texts, in the mishka_slug domain. The library backend ships English.
:script_resolver{module, function, args}noneGives the scripts of each :locales code instead of the built-in table. The :script_resolver option of a call wins.
:presetsA keyword list of a preset name and its optionsnoneNamed sets of options for MishkaSlug.Change. An action picks one with preset: :name. The options next to preset: win.
elixir
config :mishka_slug, :gettext_backend, MyAppWeb.Gettext
config :mishka_slug, :script_resolver, {MyApp.LocaleScripts, :scripts, []}

config :mishka_slug,
  presets: [
    public: [into: :slug, language: :language, locales: {MyApp.Sites, :languages, []}]
  ]

Set them 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. Pass them to each call, or keep the ones many resources share in a preset. See Write slugs with the Ash extension for presets in use.

Messages

The texts of the mishka_slug Gettext domain:

TextUsed 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 valueA 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.3 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 and MishkaSlug.Ash use 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:

elixir
{:usage_rules, "~> 1.2", only: :dev}

usage_rules: [
  file: "CLAUDE.md",
  usage_rules: [{:mishka_slug, sub_rules: ["ash", "configuration"]}]
]