i18n: get datapath directly from resourceutil
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 14 Nov 2019 12:41:33 -0800
changeset 43673 f0bee3b1b847
parent 43672 9fb85668ee15
child 43674 5be909dbe385
i18n: get datapath directly from resourceutil The new resourceutil module is lower in the dependency graph, so we can depend directly on it and won't have to depend on the util module to inject the datapath. Differential Revision: https://phab.mercurial-scm.org/D7435
doc/gendoc.py
mercurial/i18n.py
mercurial/util.py
--- a/doc/gendoc.py	Thu Nov 14 12:33:10 2019 -0800
+++ b/doc/gendoc.py	Thu Nov 14 12:41:33 2019 -0800
@@ -26,11 +26,7 @@
 from mercurial import demandimport
 
 demandimport.enable()
-# Load util so that the locale path is set by i18n.setdatapath() before
-# calling _().
-from mercurial import util
 
-util.datapath
 from mercurial import (
     commands,
     encoding,
--- a/mercurial/i18n.py	Thu Nov 14 12:33:10 2019 -0800
+++ b/mercurial/i18n.py	Thu Nov 14 12:41:33 2019 -0800
@@ -13,6 +13,7 @@
 import sys
 
 from .pycompat import getattr
+from .utils import resourceutil
 from . import (
     encoding,
     pycompat,
@@ -45,18 +46,14 @@
         # ctypes not found or unknown langid
         pass
 
-_ugettext = None
 
-
-def setdatapath(datapath):
-    datapath = pycompat.fsdecode(datapath)
-    localedir = os.path.join(datapath, 'locale')
-    t = gettextmod.translation('hg', localedir, _languages, fallback=True)
-    global _ugettext
-    try:
-        _ugettext = t.ugettext
-    except AttributeError:
-        _ugettext = t.gettext
+datapath = pycompat.fsdecode(resourceutil.datapath)
+localedir = os.path.join(datapath, 'locale')
+t = gettextmod.translation('hg', localedir, _languages, fallback=True)
+try:
+    _ugettext = t.ugettext
+except AttributeError:
+    _ugettext = t.gettext
 
 
 _msgcache = {}  # encoding: {message: translation}
--- a/mercurial/util.py	Thu Nov 14 12:33:10 2019 -0800
+++ b/mercurial/util.py	Thu Nov 14 12:41:33 2019 -0800
@@ -1824,7 +1824,6 @@
 
 
 datapath = resourceutil.datapath
-i18n.setdatapath(datapath)
 
 
 def checksignature(func):