mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-21 23:41:01 +00:00
Use lru_cache
This commit is contained in:
parent
7e2b7fbabf
commit
9d55718a62
1 changed files with 4 additions and 4 deletions
|
@ -1,12 +1,12 @@
|
|||
import os
|
||||
import json
|
||||
from functools import cache
|
||||
from functools import lru_cache
|
||||
from flask_babel import gettext as _
|
||||
from flask_babel import lazy_gettext as _lazy
|
||||
|
||||
from markupsafe import escape, Markup
|
||||
|
||||
@cache
|
||||
@lru_cache(maxsize=None)
|
||||
def get_available_locales(only_reviewed=True):
|
||||
locales_dir = os.path.join(os.path.dirname(__file__), 'locales')
|
||||
dirs = [os.path.join(locales_dir, d) for d in os.listdir(locales_dir)]
|
||||
|
@ -28,11 +28,11 @@ def get_available_locales(only_reviewed=True):
|
|||
|
||||
return res
|
||||
|
||||
@cache
|
||||
@lru_cache(maxsize=None)
|
||||
def get_available_locale_codes(only_reviewed=True):
|
||||
return [l['code'] for l in get_available_locales(only_reviewed=only_reviewed)]
|
||||
|
||||
@cache
|
||||
@lru_cache(maxsize=None)
|
||||
def get_alternate_locale_links():
|
||||
tmpl = os.environ.get("LT_LOCALE_LINK_TEMPLATE")
|
||||
if tmpl is None:
|
||||
|
|
Loading…
Reference in a new issue