Format and sort Fluent (.ftl) translation files directly in VSCode.
Features
- Document Formatter: Integrates with VSCode's standard formatting system
- Sort Messages: Optionally sort messages alphabetically within groups (separated by blank lines)
- Format on Save: Use VSCode's standard
editor.formatOnSave setting
Usage
- Open a
.ftl file
- Right-click and select "Format Document" or press
Shift+Alt+F
- The file will be formatted according to your settings
Set this extension as the default formatter for Fluent files:
{
"[fluent]": {
"editor.defaultFormatter": "ya7010.vscode-fluent-format"
}
}
Enable format-on-save using VSCode's standard setting:
{
"[fluent]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "ya7010.vscode-fluent-format"
}
}
Settings
Configure sorting behavior:
{
"fluentFormat.sortOnFormat": false
}
Options:
fluentFormat.sortOnFormat (default: false): Sort messages alphabetically when formatting
Sorting Behavior
When sorting is enabled:
- Messages are grouped by blank lines
- Within each group, messages are sorted alphabetically by ID
- Comments at the beginning of a group are preserved
Example
Before:
# Authentication
logout = Log out
login = Log in
signup = Sign up
After formatting with sort:
# Authentication
login = Log in
logout = Log out
signup = Sign up
Requirements
This extension uses the fluent-format package for formatting.
Development / Packaging
To build the .vsix package, use the npm script (Bun-managed dependencies require skipping npm’s dependency check):
cd vscode-extension
bun run package
Do not run bunx vsce package or npx vsce package directly, or you will get ELSPROBLEMS from npm.
License
MIT