mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-05-04 20:30:39 +00:00
LT_LOCALE_LINK_TEMPLATE support
This commit is contained in:
parent
b26a3931a2
commit
bfbe848c01
3 changed files with 23 additions and 3 deletions
|
@ -13,6 +13,21 @@ def get_available_locales():
|
|||
|
||||
return ['en'] + [os.path.basename(d) for d in dirs if os.path.isdir(os.path.join(d, 'LC_MESSAGES'))]
|
||||
|
||||
@cache
|
||||
def get_alternate_locale_links():
|
||||
tmpl = os.environ.get("LT_LOCALE_LINK_TEMPLATE")
|
||||
if tmpl is None:
|
||||
return []
|
||||
|
||||
locales = get_available_locales()
|
||||
result = []
|
||||
for l in locales:
|
||||
link = tmpl.replace("{LANG}", l)
|
||||
if l == 'en':
|
||||
link = link.replace("en.", "")
|
||||
result.append({ 'link': link,'lang': l })
|
||||
return result
|
||||
|
||||
# Javascript code should use _e instead of _
|
||||
def gettext_escaped(text, **variables):
|
||||
return json.dumps(_(text, **variables))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue