codegen library
VM-only codegen and format tooling.
Apps should import package:sway/sway.dart (overlay + plurals).
The dart run sway:codegen / sway:migrate CLIs use these APIs via
package:sway/src/... or this library. Not WASM-safe (dart:io).
Classes
- ParsedLocaleFile
- Represents a parsed Sway locale file.
- SchemaDiff
- Thin wrapper around SwayValidator for codegen callers.
- SwayConfig
- Sway project configuration.
- SwayEmitResult
- Result of a multi-file codegen emit.
- SwayEmitter
- Generates type-safe nested Dart from parsed locale files.
- SwayValidator
- Validates a set of parsed locale files against the Sway format rules.
- ValidationResult
- Result of validation.
Enums
- PluralCategory
- CLDR plural categories.
Constants
-
kRtlLanguageCodes
→ const Set<
String> - Known RTL language codes.
Functions
-
isRtlLanguage(
String languageCode) → bool -
Returns
trueiflanguageCodeis a known RTL language. -
resolvePlural(
String languageCode, num count) → PluralCategory -
Resolves which plural category applies for a given
countinlanguageCode. -
supportedCategories(
String languageCode) → Set< PluralCategory> -
Returns the plural categories supported by
languageCode.
Exceptions / Errors
- SwayCodegenException
- Thrown when codegen encounters an unrecoverable error.
- SwayEncodingException
- Thrown when a locale file has non-UTF8 encoding.
- SwayFormatException
- Base exception for all Sway format-related errors.
- SwayJsonParseException
- Thrown when a locale file contains invalid JSON syntax.
- SwayValidationException
- Thrown when validation detects a schema violation.