fetch_languages.py 420 B

123456789101112
  1. #!/usr/bin/env python3
  2. from pathlib import Path
  3. codes = sorted(path.name.split('.')[0] for path in Path('nicegui/static/lang').glob('*.umd.prod.js'))
  4. with (Path(__file__).parent / 'nicegui' / 'language.py').open('w', encoding='utf-8') as f:
  5. f.write('from typing import Literal\n')
  6. f.write('\n')
  7. f.write('Language = Literal[\n')
  8. for code in codes:
  9. f.write(f" '{code}',\n")
  10. f.write(']\n')