sheety_localization 0.7.0-dev
sheety_localization: ^0.7.0-dev copied to clipboard
Generate Flutter (Dart), TypeScript and Python localization code from Google Sheets, with ICU plural/select support, validation, and AI-assisted translation of missing cells.
sheety_localization example #
A small, synthetic spreadsheet ("Sheety Notes") turned into Flutter, TypeScript
and Python code. No Google account is needed: the sheet is read from
snapshot.json, an offline copy in the format
--dump-snapshot writes.
| File | What it is |
|---|---|
sheety.yaml |
The configuration: input, sheet filters, three targets |
snapshot.json |
The sheets help, app, sign-up (base language de) and backend-mail (mustache syntax) |
dart/ |
A Flutter package: pubspec.yaml and test/ are hand-written, lib/ is generated |
ts/ |
An npm package: package.json and tsconfig.json are hand-written, src/i18n/ is generated |
python/ |
A Python distribution: pyproject.toml is hand-written, src/sheety_notes_l10n/ is generated |
The generated directories, and the hand-written packaging files next to them, are in the repository. They are not in the pub.dev archive.
Regenerate #
From the repository root:
dart run sheety_localization:generate --config=example/sheety.yaml
Using example/sheety.yaml
Reading snapshot example/snapshot.json...
Read 3 sheets, 3 used by dart, ts, python
dart: 2 scope(s) -> example/dart/lib (13 added, 0 changed, 0 removed, 0 unchanged)
ts: 2 scope(s) -> example/ts/src/i18n (21 added, 0 changed, 0 removed, 0 unchanged)
python: 2 scope(s) -> example/python/src/sheety_notes_l10n (16 added, 0 changed, 0 removed, 0 unchanged)
Done.
(The real output prints absolute paths. Add -v to also list every file and
the info diagnostics: the synthetic pt locale and the fallbacks.)
Run it with --check to see whether the committed output is still up to
date. That is the command to use in CI. It exits with 1 when a file would
change.
What the sheet shows #
app: a declaredStringplaceholder, anintplural (=0,one, CLDR categories per language), aselect, markup tags, and an undeclared placeholder, which is typedObject.- Regional columns:
pt_BRhas noptcolumn, so aptlocale is synthesized from it.arhas a column of its own and keeps its own texts.ar_EGoverrides only the cell it fills (greeting); every other message falls back toar, and then toen. - A short row:
lastSynchas noar/ar_EGcells, so those locales fall back. sign-up: the base (fourth) column isde, noten.backend-mail:{{name}}placeholders (listed undersyntax.mustache), where single braces are plain text. Only the Python target takes it.
Use the output #
Flutter (see dart/test/localization_test.dart):
import 'package:sheety_notes_localization/localization.dart';
MaterialApp(
localizationsDelegates: [
...AppLocalization.localizationsDelegates,
SignUpLocalization.delegate,
],
supportedLocales: AppLocalization.supportedLocales,
home: Builder(
builder: (context) => Text(AppLocalization.of(context).notes(3)),
),
);
TypeScript:
import { app } from '@acme/sheety-notes-l10n';
const t = await app.loadMessages(navigator.languages);
t.notes({ count: 3 }); // "3 Notizen" for de-AT
Python:
from sheety_notes_l10n import backend_mail
backend_mail.get("de-CH, de;q=0.9, en;q=0.5").welcome_subject(name="Alice")
# 'Willkommen bei Sheety Notes, Alice!'
The package README documents every option.