simplified locale settings

This commit is contained in:
Martin Wagner 2021-12-29 17:20:52 +01:00
parent efabfca7d8
commit e746812c7d
2 changed files with 4 additions and 5 deletions

View File

@ -1,5 +1,6 @@
conf = configuration_data() conf = configuration_data()
conf.set('RESOURCES_DIR', resources_dir) conf.set('RESOURCES_DIR', resources_dir)
conf.set('LOCALE_DIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale'))
configure_file( configure_file(
input: 'mpdevil.in', input: 'mpdevil.in',

View File

@ -32,16 +32,14 @@ import os
import sys import sys
import re import re
import locale import locale
from gettext import gettext as _, ngettext, textdomain, bindtextdomain
try: try:
locale.setlocale(locale.LC_ALL, "") locale.setlocale(locale.LC_ALL, "")
except locale.Error as e: except locale.Error as e:
print(e) print(e)
from gettext import gettext as _, ngettext, textdomain, bindtextdomain bindtextdomain("mpdevil", localedir="@LOCALE_DIR@")
textdomain("mpdevil") textdomain("mpdevil")
if os.path.isfile("/.flatpak-info"): # test for flatpak environment
bindtextdomain("mpdevil", "/app/share/locale")
else:
bindtextdomain("mpdevil", localedir=None) # replace "None" by a static path if needed (e.g when installing on a non-FHS distro)
Gio.Resource._register(Gio.resource_load(os.path.join("@RESOURCES_DIR@", "mpdevil.gresource"))) Gio.Resource._register(Gio.resource_load(os.path.join("@RESOURCES_DIR@", "mpdevil.gresource")))
COVER_REGEX=r"^\.?(album|cover|folder|front).*\.(gif|jpeg|jpg|png)$" COVER_REGEX=r"^\.?(album|cover|folder|front).*\.(gif|jpeg|jpg|png)$"