Translations editor — Settings block
Prosettings-translations-editor · for app, settings pages
Translations editor
A key-by-key source and translation table with local drafts and host-controlled saving.
Documentation
Installation
One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).
pnpm dlx shadcn-vue@latest add @trame/settings-translations-editorUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import SettingsTranslationsEditor from '@/components/trame/blocks/settings/settings-translations-editor.vue'
const props = {
title: "Every word, in the right language",
description: "Prepare your workspace’s texts and review them before they go live.",
sourceLanguage: "English",
languages: [
{
code: "es",
name: "Spanish",
done: 3,
total: 6,
status: "Review in progress"
},
{
code: "de",
name: "German",
done: 1,
total: 6,
status: "In preparation"
}
],
entries: [
{
id: "welcome",
key: "workspace.welcome",
source: "Welcome to your workspace",
context: "Title of the home page after sign-in.",
translations: [
{
language: "es",
text: "Bienvenido a tu espacio de trabajo",
status: "done"
},
{
language: "de",
text: "Willkommen in Ihrem Arbeitsbereich",
status: "done"
}
]
},
{
id: "invite",
key: "team.invitation",
source: "Invite your team to join you.",
context: "Invitation shown when the workspace has only one member.",
translations: [
{
language: "es",
text: "Invita a tu equipo a unirse.",
status: "review"
}
]
}
],
save: "save-translation",
options: {
language: "es"
}
}
</script>
<template>
<SettingsTranslationsEditor v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title* | string | Wordsthe section’s heading |
| description | string | Wordsa few words saying more, under the heading |
| sourceLanguage* | string | Wordsthe language the texts are written in |
| languages* | Language[] | Datathe languages, each with how much is translated |
| entries* | Entry[] | Datathe entries shown, in order |
| save | string | Actiona named action of the page |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Language languages[] · 5 props
| Prop | Type | Description |
|---|---|---|
| code* | string | Datathe language’s code, e.g. "fr" |
| name* | string | Wordsthe language’s name |
| total* | number | how many texts there are |
| done* | number | how many texts are translated |
| status | string | Wordsthe language’s status, in the host’s words |
Entry entries[] · 5 props
| Prop | Type | Description |
|---|---|---|
| id* | string | Datathe entry’s id |
| key* | string | Datathe text’s key |
| source* | string | Wordsthe text in the source language |
| context | string | Wordswhere the text appears, to help the translator |
| translations* | Translation[] | Datathe text in each language |
Translation entries[].translations[] · 3 props
| Prop | Type | Description |
|---|---|---|
| language* | string | Datathe language’s code |
| text | string | Wordsthe translation’s text |
| status* | 'missing' | 'review' | 'done' | where the translation stands |
Options options · 2 props
| Prop | Type | Description |
|---|---|---|
| language | string | Datathe code of the language shown first; the first language by default |
| mood | 'inverse' | 'brand' | 'warm' | 'tint' | string | a band of the page that redefines the theme surfaces inside it |
What it asks your app for
The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).
| Member | What it is for |
|---|---|
| href | the address an action leads to, or null to hide what leads there |
| act | runs a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error } |
| can | whether the page has this action |
| cartCount | the cart badge’s number |
| cartDrawer | whether your app has a cart drawer |
| cartOpen | whether the cart drawer is open |
| label | your word for an interface key, or undefined to keep the block’s own |
The words it says itself, in English and French; label(key) replaces any of them:
| Key | English | French |
|---|---|---|
| newsletter.already | You are already subscribed. | Vous êtes déjà inscrit. |
| newsletter.done | Done: you are subscribed. | C’est noté : vous êtes inscrit. |
| newsletter.invalid | Check the email address. | Vérifiez l’adresse e-mail. |
| newsletter.tooMany | Too many attempts, try again in a moment. | Trop de tentatives, réessayez dans un moment. |
Features
- Every word in the server HTML
- Same markup in Vue and React
- Theme tokens only: every theme, light and dark
- Shows what you give it, invents nothing
- No motion; still under reduced motion
- Real buttons and links, a visible focus
- Asks your app through actions:
save - Reads
languages,translationsfrom your app
A settings section, for app, settings pages; it uses @vueuse/core, class-variance-authority, clsx, tailwind-merge.
More settings blocks
- Opening hours week rows: a ruled row per day, its open switch and its ranges side by side, the exceptions listed under the week: the full settings page of a shop, a restaurant or a practice.
- Opening hours with exceptions: the week in a narrow column beside the dated exceptions, each one a card with its date as a calendar leaf: a business whose year has many closed days and special hours.
- Profile editor compact card: an account with few public fields: one narrow centred card, the portrait on top, a few fields and one full-width save button.
- Profile editor cover header: a profile with a cover picture: a wide card with the cover and the portrait over its edge, each with its own button, the fields in cards under it.
- Profile editor with preview: a creator, seller or member profile that others see: the form in cards, and beside it a card that repeats exactly what is typed.
- Sso split: A settings page with room to the side: the values to copy in a quiet panel on one side, the provider’s form on the other, so the admin copies and pastes across without scrolling.
- Sso stacked: Single sign-on among other settings pages: one column of cards, the status first, then the values to copy, the provider’s details and the switch, saved at the foot.
- Sso steps: A first setup, or an admin who has never done it: the same settings as three numbered steps (copy these, paste yours, turn it on) along a rail.