mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-12-18 08:27:03 +02:00
Use lru_cache
This commit is contained in:
parent
7e2b7fbabf
commit
9d55718a62
@ -1,12 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from functools import cache
|
from functools import lru_cache
|
||||||
from flask_babel import gettext as _
|
from flask_babel import gettext as _
|
||||||
from flask_babel import lazy_gettext as _lazy
|
from flask_babel import lazy_gettext as _lazy
|
||||||
|
|
||||||
from markupsafe import escape, Markup
|
from markupsafe import escape, Markup
|
||||||
|
|
||||||
@cache
|
@lru_cache(maxsize=None)
|
||||||
def get_available_locales(only_reviewed=True):
|
def get_available_locales(only_reviewed=True):
|
||||||
locales_dir = os.path.join(os.path.dirname(__file__), 'locales')
|
locales_dir = os.path.join(os.path.dirname(__file__), 'locales')
|
||||||
dirs = [os.path.join(locales_dir, d) for d in os.listdir(locales_dir)]
|
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
|
return res
|
||||||
|
|
||||||
@cache
|
@lru_cache(maxsize=None)
|
||||||
def get_available_locale_codes(only_reviewed=True):
|
def get_available_locale_codes(only_reviewed=True):
|
||||||
return [l['code'] for l in get_available_locales(only_reviewed=only_reviewed)]
|
return [l['code'] for l in get_available_locales(only_reviewed=only_reviewed)]
|
||||||
|
|
||||||
@cache
|
@lru_cache(maxsize=None)
|
||||||
def get_alternate_locale_links():
|
def get_alternate_locale_links():
|
||||||
tmpl = os.environ.get("LT_LOCALE_LINK_TEMPLATE")
|
tmpl = os.environ.get("LT_LOCALE_LINK_TEMPLATE")
|
||||||
if tmpl is None:
|
if tmpl is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user