Skip to content

Instantly share code, notes, and snippets.

@flozz
Last active June 6, 2025 09:06
Show Gist options
  • Save flozz/688aad127ce594c3edc5bf10df8684f1 to your computer and use it in GitHub Desktop.
Save flozz/688aad127ce594c3edc5bf10df8684f1 to your computer and use it in GitHub Desktop.
Quick and dirty Fluent (FTL) checker
#!/usr/bin/env python3
"""
ftl-checker.py - Quick and dirty Fluent (FTL) checker.
DEPENDENCIES:
pip install fluent-compiler
USAGE:
./ftl-checker.py [message.ftl [message2.ftl [...]]]
LICENSE:
Copyright © 2025 Fabien LOISON <https://blog.flozz.fr>
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
"""
import sys
from fluent_compiler.compiler import compile_messages
from fluent_compiler.resource import FtlResource
def check_ftl_file(filename):
compiled = compile_messages("en", [FtlResource.from_file(filename)])
for _, error in compiled.errors:
print(error.message)
return bool(compiled.errors)
def main(args=sys.argv[1:]):
if not args:
print(__doc__)
sys.exit(1)
has_errors = False
for filename in args:
has_errors |= check_ftl_file(filename)
if has_errors:
sys.exit(2)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment