PhoenixKitEcommerce.Vocabulary (PhoenixKitEcommerce v0.2.0)

Copy Markdown View Source

What the storefront calls the things it sells.

A shop selling colour grading and camera crews reads badly when every heading says "Products", and a shop selling both needs a word that covers each. This module is the single place that decides, driven by the shop_catalog_vocabulary setting:

  • "products" — the default, and what every existing install keeps
  • "services" — "Services", "No services match your filters"
  • "mixed" — neutral wording ("Items", "Nothing matches your filters")
               for a shop selling both

Why whole sentences and not a swappable noun

The obvious implementation — one noun interpolated into "No %{noun} available" — produces broken Russian and Estonian. Slavic and Finnic languages inflect the noun for case, and the case is chosen by the surrounding sentence: "Нет товаров" and "Нет услуг" are both genitive plural, but the stems and endings differ, and other sentences in this module need nominative, partitive or accusative. A translator handed "Нет %{noun}" cannot produce correct output for any noun they were not shown.

So every variant is a complete gettext/1 literal. That is more msgids, and it is the only shape that lets a translator write a correct sentence. It also keeps extraction honest: each literal is visible to mix gettext.extract.

This is NOT product_type

product_type (physical | digital) is a FULFILMENT axis — it decides whether a line needs shipping. Vocabulary is a presentation axis. A shop selling services marks them digital so they do not ask for a delivery address, and that is correct and unrelated to what the catalogue heading says. Conflating the two would force a mixed shop to choose between shipping a physical good and calling it the right word.

Summary

Functions

"12 products found" — the count of matches on a category page.

The configured vocabulary; falls back to "products" for any unknown value.

Valid values, for building the settings selector.

The setting key, so the settings UI and tests do not re-spell it.

"Showing 12 of 40 products" — the pagination status line.

Functions

add_failed()

add_some_to_start()

all_items()

browse_all()

browse_cta()

collection_blurb()

count_found(count)

"12 products found" — the count of matches on a category page.

A plural literal per vocabulary rather than a shared "%{count} items found": the noun is the word being chosen here, and Russian inflects it for a case the count itself selects (1 товар, 2 товара, 5 товаров), which is why each clause is its own ngettext/4 and not a noun interpolated into one.

current()

The configured vocabulary; falls back to "products" for any unknown value.

heading()

item_column()

none_available()

none_in_category()

none_match_filters()

not_found()

options()

Valid values, for building the settings selector.

setting_key()

The setting key, so the settings UI and tests do not re-spell it.

showing_of(shown, total)

"Showing 12 of 40 products" — the pagination status line.

Same reasoning as count_found/1. The plural is chosen by the TOTAL, which is the number the noun agrees with in the source sentence.

unavailable_gone()

unavailable_now()