Feature: support additional languages (closes #29)

de,es,fr,it,jp are supported for now, pull requests for additional languages are welcome!
This commit is contained in:
sigma67 2020-07-09 18:19:09 +02:00
commit 76453bb155
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
21 changed files with 549 additions and 70 deletions

View file

@ -2,6 +2,8 @@ import re
from http.cookies import SimpleCookie
from hashlib import sha1
import time
from functools import wraps
import locale
def prepare_browse_endpoint(type, browseId):
@ -48,5 +50,16 @@ def get_authorization(auth):
return "SAPISIDHASH " + unix_timestamp + "_" + sha_1.hexdigest()
def to_int(string):
return int(string.split(' ')[0].replace(',', ''))
def to_int(string, language):
locale.setlocale(locale.LC_ALL, language)
number = string.split(' ')[0]
return locale.atoi(number)
def i18n(method):
@wraps(method)
def _impl(self, *method_args, **method_kwargs):
method.__globals__['_'] = self.lang.gettext
return method(self, *method_args, **method_kwargs)
return _impl