Words and labels
The copy system, overriding labels and the registries of keys.
Every word a component draws is in a keyed table, in English and Arabic. Nothing is written inline, so any word can be overridden, and the build of these docs can list them: each component page has a Labels table read from the component's own table.
Three levels
- Built in. The kit's words are
CORE_COPY(keyed by component, inlib/copy.ts); the shell's areSHELL_COPY; each block and PR component keeps its own table beside it. - The provider.
BricksProvider labels={{ key: { en: {…}, ar: {…} } }}overrides any key, per language, merging with the built-in table. A preset can carrylabelstoo (the TRNDR preset does, for the coupon chip, the score ring and "Managed by TRNDR"). - The component. Package components (shell, blocks, PR) also take their own
labelsorcopyprop, which wins over the provider's.
Each level only has to give the keys it changes:
Three levels of override
A component's built-in words, then the provider's labels for that component and language, then the component's own labels prop (package components) or its language prop. Each level only has to give the keys it changes.
Code
import { BricksProvider, ListToolbar, Pager, ScoreRing, SaveBar, useLanguage } from '@ergasti/bricks';
function Levels() {
const language = useLanguage();
return (
<div style={{ display: 'grid', gap: 18, maxWidth: 560 }}>
<div><p className="kit-muted">Built in</p><SaveBar dirty onSave={() => {}} onDiscard={() => {}} /></div>
<BricksProvider labels={{ saveBar: { en: { save: 'Publish' }, ar: { save: 'انشر' } } }}>
<div><p className="kit-muted">Provider: labels.saveBar.{language}.save</p><SaveBar dirty onSave={() => {}} onDiscard={() => {}} /></div>
</BricksProvider>
<div>
<p className="kit-muted">A function word: pager.showing takes (from, to, total)</p>
<BricksProvider labels={{ pager: { en: { showing: (from, to, total) => `${from} to ${to} of ${total} creators` } } }}>
<Pager page={2} lastPage={5} total={46} perPage={10} loading={false} label="Creators" onPage={() => {}} />
</BricksProvider>
</div>
<div style={{ display: 'flex', gap: 24 }}>
<ScoreRing value={74} />
<BricksProvider labels={{ scoreRing: { en: { label: 'Creator score', title: (n) => `Creator score ${n} / 100` }, ar: { label: 'تقييم الصانع', title: (n) => `تقييم الصانع: ${n} من 100` } } }}><ScoreRing value={74} /></BricksProvider>
</div>
<ListToolbar reset={{ active: true, onReset: () => {} }} />
</div>
);
}A word is either a string or a function that takes values and returns a string (showing: (from, to, total) => …). The Labels table on a component page shows a function word with the names of its values in braces, for example Showing {from}–{to} of {total}.
Keys
The provider's labels has one key per component. There are two sets: the kit's keys (KitCopyKey, the keys of CORE_COPY) and the packages' keys (PackageCopyKey: shell, brand blocks and PR blocks). The two sets never overlap (a compile-time check). The table lists each key and the component pages that read it.
133 keys: 32 kit keys and 101 package keys, found by reading each component's source for useCopy and usePackageCopy.
| Key | Set | Words | Read by |
|---|---|---|---|
asyncBlock | Kit | 1 | AsyncBlock |
avatarStack | Kit | 2 | AvatarStack, BrandStack |
bulkBar | Kit | 3 | BulkBar |
buttonLink | Kit | 1 | ButtonLink |
charts | Kit | 1 | shared by several components |
copyLink | Kit | 3 | CopyLink |
couponChip | Kit | 3 | CouponChip |
dataTable | Kit | 7 | DataTable |
delta | Kit | 3 | Delta |
dialog | Kit | 2 | DialogSkeleton |
followersCell | Kit | 1 | FollowersCell |
heroCard | Kit | 6 | HeroCard |
keyValue | Kit | 1 | KeyValue |
listState | Kit | 2 | ListState |
listToolbar | Kit | 6 | ListToolbar |
moneyNote | Kit | 4 | MoneyNote |
notifications | Kit | 10 | NotificationsMenu |
pager | Kit | 7 | Pager |
personCell | Kit | 1 | CreatorCell, PersonCell |
platforms | Kit | 3 | FollowersCell, PlatformPill |
proofButton | Kit | 3 | ProofButton |
proofList | Kit | 1 | ProofList |
rankMedal | Kit | 1 | RankMedal |
ring | Kit | 1 | Ring |
rowList | Kit | 2 | RowList |
saveBar | Kit | 4 | SaveBar |
scoreRing | Kit | 2 | ScoreRing |
shareBar | Kit | 1 | ShareBar |
sortSelect | Kit | 1 | SortSelect |
stepTimeline | Kit | 3 | StepTimeline |
toast | Kit | 1 | ToastRegion |
toolbar | Kit | 1 | Toolbar |
activityLog | Package | 3 | ActivityLog |
bonusCard | Package | 4 | BonusCard, BonusDetail |
bundleCard | Package | 8 | BundleCard |
bundleGrid | Package | 2 | BundleGrid |
bundlePurchaseSummary | Package | 16 | BundlePurchaseSummary |
bundleResultBanner | Package | 6 | BundleResultBanner |
challengeCard | Package | 11 | ChallengeCard, ChallengeDetail |
challengeDetail | Package | 7 | ChallengeDetail |
challengeRequestForm | Package | 42 | ChallengeRequestForm |
commissionInput | Package | 13 | CommissionInput, CommissionRate |
copyLinkField | Package | 4 | CopyLinkField |
creatorProfilePanel | Package | 16 | CreatorProfilePanel, ScoreCard |
defaultableSetting | Package | 16 | DefaultableSetting |
findCreatorCard | Package | 9 | FindCreatorCard, FollowerLine |
giftProductsPicker | Package | 10 | GiftProductsPicker |
giftRulesCard | Package | 18 | GiftRulesCard |
giftStockList | Package | 7 | GiftStockList |
groupCard | Package | 4 | GroupCard, GroupPanel |
groupForm | Package | 9 | GroupForm |
groupPanel | Package | 15 | GroupPanel |
liveChallengeCard | Package | 8 | LiveChallengeCard |
membersPicker | Package | 5 | MembersPicker |
messageHistoryItem | Package | 24 | MessageHistoryItem |
messageHistoryList | Package | 7 | MessageHistoryList |
messagesPanel | Package | 7 | MessagesPanel |
myCreatorPanel | Package | 16 | MyCreatorPanel |
payoutBatchDetail | Package | 11 | PayoutBatchDetail |
payoutWindowCard | Package | 4 | PayoutWindowCard |
prAdjustWallet | Package | 12 | AdjustWalletDialog |
prAnnouncementComposer | Package | 9 | AnnouncementComposer |
prApprovals | Package | 12 | ApprovalActions, ApprovalRow, QueueHeader, WaitingCell |
prAudiencePicker | Package | 20 | AudiencePicker |
prBrandDetail | Package | 20 | BrandDetailHeader, BrandWalletCard, ViewAsBanner |
prBrandFee | Package | 11 | BrandFeeDialog |
prBrandGiftStock | Package | 7 | BrandGiftStock |
prBrandRequest | Package | 11 | BrandRequestCard |
prBuilderStep | Package | 5 | BuilderStepCard |
prBulkBar | Package | 3 | PrBulkBar |
prCampaignChallenges | Package | 7 | CampaignChallenges |
prChallengeBuilder | Package | 61 | ChallengeAudienceFields, ChallengeBasicsFields, ChallengeRewardFields |
prChallengeCard | Package | 19 | PrChallengeCard |
prChallengeGiftPicker | Package | 10 | ChallengeGiftPicker |
prChallengeStatusFilter | Package | 2 | ChallengeStatusFilter |
prChallengeSummary | Package | 46 | ChallengeSummary, SummarySection |
prChangeOwner | Package | 10 | ChangeOwnerDialog |
prChangeRequests | Package | 13 | CampaignChangeRequests |
prChannelPicker | Package | 4 | ChannelPicker |
prCommissionChange | Package | 17 | CommissionChangeForm |
prCountPill | Package | 3 | PrCountPill |
prCreatorDrawer | Package | 24 | PrCreatorDrawer |
prCreatorPick | Package | 11 | CreatorPickDialog |
prCustomerCard | Package | 28 | CustomerAffiliatesCard |
prCustomerSwitch | Package | 11 | CustomerAffiliatesSwitch |
prDecisionsCard | Package | 3 | DecisionsCard |
prDecisionTag | Package | 2 | DecisionTag |
prEditing | Package | 6 | ChangePreview, Stepper |
prFraudCaseDetail | Package | 30 | FraudCaseDetail |
prFraudCaseRow | Package | 11 | FraudCaseRow |
prFraudDecision | Package | 13 | FraudDecisionBar |
prGiftAnalytics | Package | 10 | GiftShipmentCounts |
prGiftAttention | Package | 4 | GiftAttentionList |
prGifts | Package | 45 | GiftClaimCheck, ShipmentSummary |
prGiftShipment | Package | 31 | GiftShipmentCard |
prGiftSide | Package | 13 | BrandGiftStockCard, GiftShipmentTimeline |
prGiftStatusFilter | Package | 2 | GiftStatusFilter |
prLeaderboard | Package | 23 | Leaderboard |
prLoginCard | Package | 12 | LoginCard |
prLoginLayout | Package | 4 | LoginLayout |
prMessageCells | Package | 7 | AudienceLabel, OpenRate, SenderCell |
prMessageDrawer | Package | 10 | MessageDrawer |
prMessageFields | Package | 8 | MessageFields |
prMessagePreview | Package | 8 | MessagePreview |
prMiniList | Package | 2 | MiniList, MiniRow |
prNextCampaign | Package | 19 | NextCampaignCard, ScheduleCampaignDialog |
productCell | Package | 1 | ProductCell |
progressRow | Package | 2 | ProgressRow |
prOtpStep | Package | 11 | OtpStep |
prPermissionMatrix | Package | 4 | PermissionMatrix |
prPortalFrame | Package | 20 | PrPortalFrame |
prProgramCards | Package | 15 | AffiliateProgramCard, ProgramStatusCard |
prReasonDialog | Package | 9 | ReasonDialog |
prReceiptUpload | Package | 15 | ReceiptUpload |
prRecordGifts | Package | 18 | RecordGiftsDialog |
prRequestCards | Package | 13 | RequestGiftsCard, RequestHandled, RequestWalletCard |
prRequestChallenge | Package | 4 | RequestChallengeCard |
prScore | Package | 28 | ScoreBreakdown, ScoreExplainer |
prSenderPicker | Package | 5 | SenderPicker |
prSettings | Package | 5 | NumberSetting, PlatformDefaultRow |
prTierChange | Package | 13 | TierChangeDialog |
prTierLadder | Package | 41 | TierLadder |
prTierMoves | Package | 8 | TierMoveList |
prUsageBar | Package | 1 | UsageBar |
prWalletHealth | Package | 4 | WalletHealthPill |
prWarehouse | Package | 14 | WarehouseDetailsCard, WarehouseNote |
rowActions | Package | 8 | RowActions |
settingsSection | Package | 2 | SettingsSection |
specialCommissionForm | Package | 10 | SpecialCommissionForm |
topUpAmountPicker | Package | 12 | TopUpAmountPicker |
topUpResultBanner | Package | 5 | TopUpResultBanner |
walletHealthCard | Package | 14 | WalletHealthCard |
walletLedger | Package | 9 | WalletLedger |
CORE_COPY
constant
The generic defaults. Words that name a brand (TRNDR score, Managed by TRNDR) are in the preset instead.
const CORE_COPY: KitCopyTableSource: src/lib/copy.ts (line 130)
SHELL_COPY
constant
The shell's built-in words in English and Arabic (menu, close, skip link, usage meter and so on), keyed by language. AppShell and its parts read them; override per component with BricksProvider labels or their own props.
const SHELL_COPY: Readonly<Record<Lang, { skipToMain: string; sidebar: string; bottomNav: string; navSheet: string; menu: string; close: string; closeMenu: string; expandSidebar: string; collapseSidebar: string; more: string; breadcrumbs: string; otherLanguage: string; otherLanguageShort: string; searchLabel: string; searchPlaceholder: string; searchNone: string; searchFailed: string; searchLoading: string; errorText: string; retry: string; signOut: string; account: string; accountSuffix: string; usageNoLimit: string; usageOf: (used: string, limit: string) => string; }>>Source: src/shell/copy.ts (line 69)
Wording rules the library follows
- Words that name a brand (a product name, a currency) live in a preset, never in the generic tables.
- No inline language ternaries: a guard test fails on
language === 'ar' ? '…' : '…'. - Say the outcome in a toast ("Approved. Sara gets a WhatsApp."), and write validation messages as the next step.
Labels in lists
labelText(label, language) resolves a label that is either a plain string or an { en, ar } pair; the shell's navigation uses it.
labelText
function
The label in language.
function labelText(label: NavLabel, language: Lang): stringProp
Type
Source: src/shell/types.ts (line 9)