pvtro 0.9.0
pvtro: ^0.9.0 copied to clipboard
CLI tool for coordinating slang translations across Flutter packages.
Examples #
This directory contains two end-to-end fixtures that show how PVTRO discovers slang translation layers across a package graph and generates a single integration file for the root app.
Use this document as the entry point, then open the fixture-specific READMEs for the exact package layout and commands.
What PVTRO Does In These Examples #
For each example, PVTRO runs from the root app and:
- reads the root package graph from
.dart_tool/package_config.json - finds packages that expose a generated
slanglayer underlib/ - orders them with the root package first and dependencies after that
- generates
lib/pvtro.g.dartin the root app - emits:
pvtroWrapper({required Widget child})pvtroSyncPackageLocales(String rawLocale)
The generated wrapper nests each package's TranslationProvider in discovery order. The locale sync helper forwards LocaleSettings.setLocaleRaw(rawLocale) to every discovered package.
If no translation layer is found, PVTRO does nothing.
Included Fixtures #
integration_check_1 #
See integration_check_1/README.md.
This is the lightweight fixture.
- Uses checked-in stub translation files.
- Has no
pvtro.yaml, so both entrypoints use the default output path. - Good for verifying package discovery and output shape quickly.
Expected generated file:
lib/pvtro.g.dart
integration_check_2 #
See integration_check_2/README.md.
This is the real fixture.
- Uses actual
slang.yamlplus locale JSON inputs. - Uses real
dart run slangoutputs in all three packages. - Includes
pvtro.yamlwith a custom copied output target. - Good for validating the real dual-mode contract.
Expected generated files:
lib/pvtro.g.dartlib/generated/pvtro_wrapper.g.dart
How The Graph Is Structured #
Both fixtures model the same dependency chain:
- Root app
- Direct path dependency with its own
slanglayer - Nested path dependency under that package with its own
slanglayer
That means the generated wrapper should compose three TranslationProviders, and the sync helper should call LocaleSettings.setLocaleRaw three times.
How To Run An Example #
From the fixture root:
flutter pub get
dart run pvtro --verbose
dart run build_runner build --delete-conflicting-outputs
For integration_check_2, regenerate the slang outputs in each package first, as described in its local README.
Output Behavior #
Both fixtures demonstrate the same core behavior:
dart run pvtroanddart run build_runner buildshare the same discovery logic- the canonical generated artifact is always
lib/pvtro.g.dart - if
pvtro.yamlsets a differentoutput, PVTRO also writes a copy to that configured path
In practice:
integration_check_1shows the default-path flowintegration_check_2shows the canonical-plus-copy flow
What To Inspect After Generation #
Open the generated root file and confirm these points:
- all imports use
package:paths with POSIX separators - the root app provider is the outermost
TranslationProvider - nested package providers appear inside it in dependency order
pvtroSyncPackageLocalesincludes one call per discovered package
If one of those conditions is wrong, the example has exposed a regression in discovery or generation.