Multi-Locale & Translation Isolation
CopyPatch provides strict per-locale data isolation. Each language code (e.g. en, tr, de, es) maintains its own independent published snapshot, draft revision, and edit history.
How Locale Isolation Works
- Zero Cross-Contamination: Publishing edits in
trhas no effect onen,de, or any other locale. - Independent Revision Counters: Revision numbers are tracked per locale. If two editors work on English and Turkish concurrently, their revisions never conflict.
- Fallback Resolution: When a key has not yet been edited in storage for a given locale, CopyPatch gracefully renders the component's default fallback text.
Routing Integration Example (Next.js App Router)
Pass the route's active locale parameter to readPublishedSnapshot() and NextCopyPatchProvider:
app/[locale]/layout.tsx
// app/[locale]/layout.tsx
import { NextCopyPatchProvider } from '@copypatch/next';
import { readPublishedSnapshot } from '@copypatch/next/server';
import { copypatch } from '@/lib/copypatch';
export default async function LocaleLayout({
children,
params,
}: {
children: React.ReactNode;
params: Promise<{ locale: string }>;
}) {
const { locale } = await params;
const snapshot = await readPublishedSnapshot(copypatch, locale);
return (
<html lang={locale}>
<body>
<NextCopyPatchProvider locale={locale} initialSnapshot={snapshot}>
{children}
</NextCopyPatchProvider>
</body>
</html>
);
} Component-Level Localization
Supply locale-appropriate default strings inside JSX children or hook fallback parameters:
PricingHeader.tsx
import { EditableText, useCopyPatch } from '@copypatch/react';
export function PricingHeader({ locale }: { locale: string }) {
// English fallback: "Simple Pricing" / Turkish fallback: "Basit Fiyatlandırma"
const defaultTitle = locale === 'tr' ? 'Basit Fiyatlandırma' : 'Simple Pricing';
const ctaLabel = useCopyPatch('pricing.cta', locale === 'tr' ? 'Hemen Başla' : 'Start Now');
return (
<div className="pricing-header">
<EditableText contentKey="pricing.title" as="h2">
{defaultTitle}
</EditableText>
<button type="button">{ctaLabel}</button>
</div>
);
} Locale Format & Validation Rules
CopyPatch validates locale strings using standard BCP 47 and alphanumeric tag conventions before performing any storage read or mutation:
| Valid Examples | Description |
|---|---|
en, tr, de, ja | Two-letter ISO 639-1 language codes. |
en-US, pt-BR, zh-CN | Language and regional country subtags. |
en_US, tr_TR | POSIX / system format tags. |
Scope Note: CopyPatch is a copy-persistence and inline editing system, not an automated translation service or an i18n URL router. You maintain full ownership of your application's routing and URL design.