feat(i18n): add Lingui runtime and development tooling

- add SSR-safe I18nProvider, Translate, locale hooks, catalog activation, and typed runtime APIs

- add consumer-owned Lingui configuration helpers and a CLI for locale creation, extraction, compilation, and project discovery

- add catalog read/write services plus a Vite development API plugin scoped to each consuming application

- add the portal-based I18nDevtool, message editor, dark-theme tracking, and standalone Message Studio

- document the consumer workflow and cover runtime, configuration, catalog, CLI, and Devtool behavior with tests
This commit is contained in:
Maofeng
2026-07-29 21:23:00 +08:00
parent 011e7d8115
commit 9e3f1d6b59
39 changed files with 2897 additions and 0 deletions
+218
View File
@@ -0,0 +1,218 @@
.i18n-message-panel {
--i18n-border: color-mix(in srgb, currentColor 14%, transparent);
--i18n-muted: color-mix(in srgb, currentColor 62%, transparent);
--i18n-surface: color-mix(in srgb, Canvas 96%, currentColor 4%);
color: CanvasText;
font-family:
Inter,
ui-sans-serif,
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
}
.i18n-message-panel *,
.i18n-message-panel *::before,
.i18n-message-panel *::after {
box-sizing: border-box;
}
.i18n-message-panel__toolbar {
position: sticky;
z-index: 2;
top: 0;
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem;
border-bottom: 1px solid var(--i18n-border);
background: color-mix(in srgb, Canvas 90%, transparent);
backdrop-filter: blur(14px);
}
.i18n-message-panel__search {
min-width: 12rem;
flex: 1;
}
.i18n-message-panel input,
.i18n-message-panel textarea,
.i18n-message-panel button {
color: inherit;
font: inherit;
}
.i18n-message-panel input[type="search"],
.i18n-message-panel textarea {
width: 100%;
border: 1px solid var(--i18n-border);
border-radius: 0.625rem;
outline: none;
background: Canvas;
}
.i18n-message-panel input[type="search"] {
height: 2.5rem;
padding: 0 0.75rem;
}
.i18n-message-panel textarea {
min-height: 5.5rem;
resize: vertical;
padding: 0.75rem;
line-height: 1.5;
}
.i18n-message-panel input[type="search"]:focus,
.i18n-message-panel textarea:focus {
border-color: AccentColor;
box-shadow: 0 0 0 3px color-mix(in srgb, AccentColor 18%, transparent);
}
.i18n-message-panel__toggle {
display: inline-flex;
align-items: center;
gap: 0.4rem;
white-space: nowrap;
font-size: 0.875rem;
}
.i18n-message-panel__count {
color: var(--i18n-muted);
font-variant-numeric: tabular-nums;
font-size: 0.8125rem;
}
.i18n-message-panel__list {
display: grid;
gap: 0.75rem;
padding: 0.75rem;
}
.i18n-message {
display: grid;
gap: 0.875rem;
padding: 1rem;
border: 1px solid var(--i18n-border);
border-radius: 0.875rem;
background: var(--i18n-surface);
}
.i18n-message[data-missing] {
border-color: color-mix(in srgb, #e8a317 55%, var(--i18n-border));
}
.i18n-message[data-obsolete] {
opacity: 0.65;
}
.i18n-message__header,
.i18n-message__actions,
.i18n-message__meta {
display: flex;
align-items: center;
gap: 0.5rem;
}
.i18n-message__header {
justify-content: space-between;
}
.i18n-message__id {
overflow-wrap: anywhere;
font-size: 0.8125rem;
}
.i18n-message__catalog {
color: var(--i18n-muted);
font-size: 0.75rem;
}
.i18n-message__source p {
margin: 0.25rem 0 0;
line-height: 1.5;
}
.i18n-message__field {
display: grid;
gap: 0.35rem;
}
.i18n-message__label {
color: var(--i18n-muted);
font-size: 0.75rem;
font-weight: 600;
letter-spacing: 0.02em;
text-transform: uppercase;
}
.i18n-message__meta {
flex-wrap: wrap;
color: var(--i18n-muted);
font-size: 0.75rem;
}
.i18n-message__actions {
justify-content: flex-end;
}
.i18n-message__status {
margin-inline-end: auto;
color: var(--i18n-muted);
font-size: 0.75rem;
}
.i18n-message-panel button {
min-height: 2.25rem;
padding: 0 0.8rem;
border: 1px solid var(--i18n-border);
border-radius: 0.55rem;
background: Canvas;
cursor: pointer;
}
.i18n-message-panel button:hover:not(:disabled) {
background: color-mix(in srgb, Canvas 90%, currentColor 10%);
}
.i18n-message-panel button:disabled {
cursor: default;
opacity: 0.45;
}
.i18n-message-panel__state {
display: grid;
min-height: 14rem;
place-items: center;
align-content: center;
gap: 0.75rem;
padding: 2rem;
color: var(--i18n-muted);
text-align: center;
}
.i18n-message-panel__state p {
margin: 0;
}
.i18n-visually-hidden {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0 0 0 0);
clip-path: inset(50%);
white-space: nowrap;
}
@media (max-width: 40rem) {
.i18n-message-panel__toolbar {
flex-wrap: wrap;
}
.i18n-message-panel__search {
flex-basis: 100%;
}
}