Docs: fix stale localization, module and contributing docs
- localization.md: the label seeders are StorefrontTranslationsSeeder (and the checkout/validation ones), not a StorefrontLabels class or lunar:install; when each runs (storefront isn't seeded on boot); translations:pull; examples use the same slug in every locale. - modules.md: core's JS/CSS is a real npm package (@boboko/core) with a Vite plugin, not files read from vendor/; bin/core-mode does the swap; open 0.x ranges instead of ^1.0; a real shop as the example app. - CONTRIBUTE.md, README.md: seeding on boot corrected; 0.* range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bfc1f92b2e
commit
79e7e9b4fd
4 files changed
+60
-75
No files matched your search
+33
-18
@@ -1,6 +1,6 @@
|
||||
# Localization
|
||||
|
||||
Storefront routes can be locale-prefixed (`/el/proionta`, `/en/products`) using a middleware
|
||||
Storefront routes can be locale-prefixed (`/el/products`, `/en/products`) using a middleware
|
||||
that reads directly from Lunar's `languages` table — the same table the Filament **Languages**
|
||||
resource manages, so there's no separate locale config to keep in sync.
|
||||
|
||||
@@ -8,7 +8,7 @@ resource manages, so there's no separate locale config to keep in sync.
|
||||
|
||||
## Why prefix every locale, including the default
|
||||
|
||||
Leaving the default locale bare at the root (`/proionta` for Greek, `/en/products` for English)
|
||||
Leaving the default locale bare at the root (`/products` for Greek, `/en/products` for English)
|
||||
creates ambiguity: is `/` the language-neutral homepage or specifically the Greek version? It
|
||||
also complicates `hreflang` (needs a self-referencing tag on the root plus a possibly-duplicate
|
||||
`x-default`) and risks duplicate content if a bot or campaign link reaches the root without a
|
||||
@@ -17,6 +17,11 @@ language signal.
|
||||
Prefixing every locale avoids this: every URL unambiguously declares its language, `hreflang`
|
||||
tags are symmetrical, and adding a locale later requires no URL restructuring.
|
||||
|
||||
|
||||
**Slugs are the same in every locale** (`/el/products/…` and `/en/products/…`, never
|
||||
`/el/proionta/…`). Only the visible content is translated. Boboko shops don't use per-locale
|
||||
slugs.
|
||||
|
||||
---
|
||||
|
||||
## Opt-in, not global
|
||||
@@ -30,8 +35,8 @@ use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware('locale')->group(function () {
|
||||
Route::get('/{locale}', HomeController::class);
|
||||
Route::get('/{locale}/proionta', ProductIndexController::class);
|
||||
Route::get('/{locale}/proionta/{slug}', ProductShowController::class);
|
||||
Route::get('/{locale}/products', ProductIndexController::class);
|
||||
Route::get('/{locale}/products/{slug}', ProductShowController::class);
|
||||
});
|
||||
```
|
||||
|
||||
@@ -198,21 +203,31 @@ registered.
|
||||
|
||||
### Seeding
|
||||
|
||||
A starter set of common e-shop labels (`nav.*`, `cart.*`, `product.*`, `auth.*`, `search.*`,
|
||||
`review.*`, `shop.*`, `pagination.*`, English + Greek) lives in
|
||||
`Modules\Core\Localization\Services\StorefrontLabels::all()` — kept as its own class, separate
|
||||
from the seeding logic, so the label list can be scanned/diffed without wading through the
|
||||
seeding mechanics.
|
||||
The default labels for every shop (`nav.*`, `footer.*`, `cart.*`, `product.*`, `shop.*`,
|
||||
`search.*`, `auth.*`, `account.*`, `orders.*`, `contact.*`, `review.*`, `wishlist.*`,
|
||||
`pagination.*`, English + Greek) live in
|
||||
`Modules\Core\Localization\Database\Seeders\StorefrontTranslationsSeeder::lines()`. Checkout and
|
||||
validation messages have their own seeders (`Modules\Core\Checkout\Database\Seeders\CheckoutTranslationsSeeder`,
|
||||
`Modules\Core\Localization\Database\Seeders\ValidationTranslationsSeeder`).
|
||||
|
||||
`Modules\Core\Command\InstallLunarCommand` (overrides Lunar's own `lunar:install`) seeds them via
|
||||
a **per-key upsert**, not an all-or-nothing "only seed if the group is empty" guard: a key already
|
||||
present in the database — including one an admin has since edited via the Filament **Language
|
||||
Lines** resource — is left untouched; only keys missing entirely are created. This is what makes
|
||||
it safe to add new keys to `StorefrontLabels::all()` later and re-run `lunar:install` on an
|
||||
already-installed store, without either silently skipping the new keys (the old guard's behavior)
|
||||
or reverting an admin's edits back to the hardcoded default (what a naive `updateOrCreate` would
|
||||
do). New writes go through `TranslationService::create()`, so the usual cache-invalidation and
|
||||
activity-log events fire for them too.
|
||||
The seeders are **additive per key**: a key already in the database, including one an admin has
|
||||
since edited in the Filament **Language Lines** resource, is left untouched; only missing keys
|
||||
are created. That makes it safe to add keys to a seeder later and re-run it on an installed store,
|
||||
without skipping the new keys or reverting an admin's edits. New lines go through
|
||||
`TranslationService::create()`, so the usual cache-invalidation and activity-log events fire.
|
||||
|
||||
**When they run:** a shop's `docker/entrypoint.sh` runs the checkout and validation seeders on
|
||||
every boot. `StorefrontTranslationsSeeder` isn't run automatically (not by `lunar:install`, not on
|
||||
boot), so run it explicitly after a core update that adds keys, or add it to the shop's
|
||||
entrypoint:
|
||||
|
||||
```bash
|
||||
php artisan db:seed --class="Modules\Core\Localization\Database\Seeders\StorefrontTranslationsSeeder"
|
||||
```
|
||||
|
||||
**Lines added in the admin** while building a storefront are copied back into the seeders with
|
||||
`php artisan boboko:translations:pull` (local mode; see `CONTRIBUTE.md`, "Translations added in
|
||||
the UI"). A key that exists only in one shop's database shows as a raw key everywhere else.
|
||||
|
||||
### Admin UI
|
||||
|
||||
|
||||
Reference in new issue
Block a user