mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Make the locale directory configurable
Add a new configuration option to specify the locale directory to use. This allows the Python scripts to find the translations, even when not being run from the source code checkout. At the same time, multiple parallel aurweb setups can still use different sets of translations. Fixes FS#59278. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
c8d99bac8e
commit
a7865ef5aa
3 changed files with 7 additions and 2 deletions
|
@ -1,8 +1,11 @@
|
||||||
import gettext
|
import gettext
|
||||||
|
|
||||||
|
import aurweb.config
|
||||||
|
|
||||||
|
|
||||||
class Translator:
|
class Translator:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self._localedir = aurweb.config.get('options', 'localedir')
|
||||||
self._translator = {}
|
self._translator = {}
|
||||||
|
|
||||||
def translate(self, s, lang):
|
def translate(self, s, lang):
|
||||||
|
@ -10,7 +13,7 @@ class Translator:
|
||||||
return s
|
return s
|
||||||
if lang not in self._translator:
|
if lang not in self._translator:
|
||||||
self._translator[lang] = gettext.translation("aurweb",
|
self._translator[lang] = gettext.translation("aurweb",
|
||||||
"../../web/locale",
|
self._localedir,
|
||||||
languages=[lang])
|
languages=[lang])
|
||||||
self._translator[lang].install()
|
self._translator[lang].install()
|
||||||
return _(s)
|
return _(s)
|
||||||
|
|
|
@ -35,6 +35,7 @@ snapshot_uri = /cgit/aur.git/snapshot/%s.tar.gz
|
||||||
enable-maintenance = 1
|
enable-maintenance = 1
|
||||||
maintenance-exceptions = 127.0.0.1
|
maintenance-exceptions = 127.0.0.1
|
||||||
render-comment-cmd = /usr/local/bin/aurweb-rendercomment
|
render-comment-cmd = /usr/local/bin/aurweb-rendercomment
|
||||||
|
localedir = /srv/http/aurweb/aur.git/web/locale/
|
||||||
# memcache or apc
|
# memcache or apc
|
||||||
cache = none
|
cache = none
|
||||||
memcache_servers = 127.0.0.1:11211
|
memcache_servers = 127.0.0.1:11211
|
||||||
|
|
|
@ -130,7 +130,8 @@ function set_lang() {
|
||||||
setcookie("AURLANG", $LANG, $cookie_time, "/");
|
setcookie("AURLANG", $LANG, $cookie_time, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
$streamer = new FileReader('../locale/' . $LANG .
|
$localedir = config_get('options', 'localedir');
|
||||||
|
$streamer = new FileReader($localedir . '/' . $LANG .
|
||||||
'/LC_MESSAGES/aurweb.mo');
|
'/LC_MESSAGES/aurweb.mo');
|
||||||
$l10n = new gettext_reader($streamer, true);
|
$l10n = new gettext_reader($streamer, true);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue