@localey/svelte
v0.1.26
Published
Svelte template adapter for Localey.
Readme
@localey/svelte
Svelte template adapter for Localey.
The @localey/svelte package enables Localey to process .svelte files. It leverages the official Svelte compiler to parse templates and identify hardcoded strings within the Svelte syntax.
Integration Details
The adapter integrates directly with the Svelte compiler's internal parsing engine. This ensures that it respects the nuances of Svelte's template logic, such as reactive statements and block-based flow control.
Extraction Capabilities
- Template Text: Identifies static text nodes within the HTML portion of the Svelte component.
- Element Attributes: Detects string literals used in element attributes and component props within the template.
- Mustache Tags: Automatically wraps extracted strings in Svelte's mustache syntax (
{t("key")}) for seamless integration with the Localey runtime.
Component Architecture
- Svelte Compiler API: Parses the component source into a comprehensive AST.
- Template Walker: Navigates the Svelte-specific AST nodes (MustacheTag, Text, Attribute) to identify localization candidates.
- Transformation Layer: Safely performs string replacements while maintaining the integrity of the component structure.
