Allow configuring country and language in core config (#81734)
* Allow configuring country and language in core config * Add script for updating list of countries * Use black for formatting * Fix quoting * Move country codes to a separate file * Address review comments * Add generated/countries.py * Get default language from owner account * Remove unused variable * Add script to generate list of supported languages * Add tests * Fix stale docsring * Use format_python_namespace * Correct async_user_store * Improve typing * Fix with_store decorator * Initialize language in core store migration * Fix startup * Tweak * Apply suggestions from code review Co-authored-by: Franck Nijhof <git@frenck.dev> * Update storage.py Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
09c3df7eb2
commit
e1338adf1a
17 changed files with 623 additions and 37 deletions
25
script/languages.py
Normal file
25
script/languages.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
"""Helper script to update language list from the frontend source."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
import requests
|
||||
|
||||
from .hassfest.serializer import format_python_namespace
|
||||
|
||||
tag = sys.argv[1] if len(sys.argv) > 1 else "dev"
|
||||
|
||||
req = requests.get(
|
||||
f"https://raw.githubusercontent.com/home-assistant/frontend/{tag}/src/translations/translationMetadata.json"
|
||||
)
|
||||
data = json.loads(req.content)
|
||||
languages = set(data.keys())
|
||||
|
||||
Path("homeassistant/generated/languages.py").write_text(
|
||||
format_python_namespace(
|
||||
{
|
||||
"LANGUAGES": languages,
|
||||
},
|
||||
generator="script.languages [frontend_tag]",
|
||||
)
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue