Merge lp:~gz/bzr/sys_prefix_share_locale_940704 into lp:bzr/2.5

Proposed by Martin Packman
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 6496
Proposed branch: lp:~gz/bzr/sys_prefix_share_locale_940704
Merge into: lp:bzr/2.5
Diff against target: 28 lines (+5/-6)
1 file modified
bzrlib/i18n.py (+5/-6)
To merge this branch: bzr merge lp:~gz/bzr/sys_prefix_share_locale_940704
Reviewer Review Type Date Requested Status
Vincent Ladeuil Needs Fixing
Review via email: mp+99984@code.launchpad.net

Commit message

Use sys.prefix not /usr when looking for installed .mo files

Description of the change

Change the fallback location to look for bzr translation files to be relative to the python installation, rather than hardcoded. For the common case, this is the same, but for user-installs and on windows, sys.prefix is something other than '/usr'. This means installing the translations separate from the bzrlib folder should now work in those situations.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

Since the locale_dir depends on the system, it's likely we'll fail on some platform sooner or later.

Can you add a config option so we know we can always work around any weird setup ?

Otherwise, just land.

review: Needs Fixing
Revision history for this message
Martin Packman (gz) wrote :

A config option at this level probably isn't useful, but the absolute fallback location may still want changing for some platforms indeed.

Revision history for this message
Martin Packman (gz) wrote :

sent to pqm by email

Revision history for this message
Vincent Ladeuil (vila) wrote :

> A config option at this level probably isn't useful, but the absolute fallback location may still want changing for some platforms indeed.

Having a config option *gives* a way to change the absolute fallback *manually* without the need to tweak any code, that's my point ;)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/i18n.py'
2--- bzrlib/i18n.py 2011-12-19 13:23:58 +0000
3+++ bzrlib/i18n.py 2012-03-29 18:00:29 +0000
4@@ -136,19 +136,18 @@
5
6 :param base: plugins can specify their own local directory
7 """
8- if hasattr(sys, 'frozen'):
9+ fs_enc = sys.getfilesystemencoding()
10+ if getattr(sys, 'frozen', False):
11 if base is None:
12- base = os.path.dirname(
13- unicode(sys.executable, sys.getfilesystemencoding()))
14+ base = os.path.dirname(unicode(sys.executable, fs_enc))
15 return os.path.join(base, u'locale')
16 else:
17 if base is None:
18- base = os.path.dirname(unicode(__file__, sys.getfilesystemencoding()))
19+ base = os.path.dirname(unicode(__file__, fs_enc))
20 dirpath = os.path.realpath(os.path.join(base, u'locale'))
21 if os.path.exists(dirpath):
22 return dirpath
23- else:
24- return '/usr/share/locale'
25+ return os.path.join(unicode(sys.prefix, fs_enc), u"share", u"locale")
26
27
28 def _check_win32_locale():

Subscribers

People subscribed via source and target branches