Fix locale scope (#125)
This commit is contained in:
parent
25d538930f
commit
26fa787b06
1 changed files with 22 additions and 21 deletions
|
|
@ -84,6 +84,7 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi
|
||||||
|
|
||||||
with open(pkg_resources.resource_filename('ytmusicapi', 'context.json')) as json_file:
|
with open(pkg_resources.resource_filename('ytmusicapi', 'context.json')) as json_file:
|
||||||
self.context = json.load(json_file)
|
self.context = json.load(json_file)
|
||||||
|
|
||||||
self.context['context']['client']['hl'] = language
|
self.context['context']['client']['hl'] = language
|
||||||
supported_languages = [
|
supported_languages = [
|
||||||
f for f in pkg_resources.resource_listdir('ytmusicapi', 'locales')
|
f for f in pkg_resources.resource_listdir('ytmusicapi', 'locales')
|
||||||
|
|
@ -93,7 +94,7 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi
|
||||||
', '.join(supported_languages))
|
', '.join(supported_languages))
|
||||||
self.language = language
|
self.language = language
|
||||||
try:
|
try:
|
||||||
locale.setlocale(locale.LC_ALL, language)
|
locale.setlocale(locale.LC_ALL, self.language)
|
||||||
except locale.Error:
|
except locale.Error:
|
||||||
with suppress(locale.Error):
|
with suppress(locale.Error):
|
||||||
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue