<div style="font-family: Helvetica; font-size: 13px; ">Hei Erik,<div><br></div><div>Thanks… That does the trick!</div><div><br></div><div>But there is still an issue regarding where the files will be installed.</div><div><br></div><div>On Ubuntu, it goes to:</div><div>/usr/local/share/locale</div><div>and this does not work because gettext looks at: /usr/share/locale</div><div><br></div><div>On mac (lion), however, it works. The installed failed go to:</div><div>/System/Library/Frameworks/Python.framework/Versions/2.7/share/locale/</div><div>And gettext looks at: /opt/local/share/locale</div><div>Even though, python seems to pick up the l10n right.</div><div>The same does not happen in Linux, unless I force the setup.py to install in /usr path…&nbsp;</div><div><br></div><div>How can I tell python to look for that directory in particular instead of the default? My concern here is that I should not hard-code this path in the gettext.translation() method, which would then not work for other people with non-standard locations, or on mac, or on Windows…</div><div><br></div><div>I read about setting up m4 alike strings in python code that would be replaced by distutils upon compilation, but I could not find any reference for that, neither if that is a solution for my problem.</div><div><br></div><div>Thanks for your help.</div></div>
                <div><div><br></div><div><span style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: small; font-family: 'courier new', monospace; ">--</span><br style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: small; font-family: 'courier new', monospace; "><b style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: small; font-family: 'courier new', monospace; ">Braga, Bruno</b><br style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: small; font-family: 'courier new', monospace; "><a href="http://www.brunobraga.net/" target="_blank" style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: small; font-family: 'courier new', monospace; ">www.brunobraga.net</a><br style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: small; font-family: 'courier new', monospace; "><a href="mailto:bruno.braga@gmail.com" target="_blank" style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: small; font-family: 'courier new', monospace; ">bruno.braga@gmail.com</a></div><div><br></div></div>
                  
                <p style="color: #A0A0A8;">On Tuesday, 6 March 2012 at 5:35 AM, Erik Bray wrote:</p><blockquote type="cite"><div>
                    <span><div><div><div>On Thu, Mar 1, 2012 at 11:02 PM, BRAGA, Bruno &lt;<a href="mailto:bruno.braga@gmail.com">bruno.braga@gmail.com</a>&gt; wrote:</div><blockquote type="cite"><div><div>Hi,</div><div><br></div><div>I am working on a project written in Python, and I would like to use i18n</div><div>functionality, but I am having some issues with it, more specifically</div><div>regarding the .mo files location, and I was hoping someone here could point</div><div>me in the right direction.</div><div><br></div><div>(1) i18n mo files location</div><div><br></div><div>Basically, I already know&nbsp;how to translate contents with gettext, but I got</div><div>stuck with the fact that it, by default, looks at</div><div>/usr/share/locale/{language} (in Linux), but the setup.py install data_files</div><div>into /usr/local/share/... unless I forcibly use absolute paths toward the</div><div>location where the files should be.</div><div><br></div><div>(2)&nbsp;install_data.data_files</div><div><br></div><div>Also, I am having a problem to install the data_files, because the</div><div>install_data command is never called. I made it work before, but I don't</div><div>understand what I am missing that worked before and not now.</div><div><br></div><div>Here is the setup.py script:</div><div><a href="https://github.com/brunobraga/termsaver/blob/master/setup.py">https://github.com/brunobraga/termsaver/blob/master/setup.py</a></div><div><br></div><div>And this is the i18n module I am using as base for localizing all text in</div><div>the application:</div><div><a href="https://github.com/brunobraga/termsaver/blob/master/termsaverlib/i18n.py">https://github.com/brunobraga/termsaver/blob/master/termsaverlib/i18n.py</a></div><div><br></div><div>Here is the output of a clean install:</div><div><br></div><div>bruno@development3;~$&nbsp;&nbsp;sudo python setup.py install --record</div><div>/tmp/termsaver.install.record.txt</div><div>[sudo] password for bruno:</div><div>running install</div><div>running build</div><div>running build_py</div><div>creating build</div><div>creating build/lib.linux-i686-2.7</div><div>creating build/lib.linux-i686-2.7/termsaverlib</div><div>copying termsaverlib/constants.py -&gt; build/lib.linux-i686-2.7/termsaverlib</div><div>copying termsaverlib/i18n.py -&gt; build/lib.linux-i686-2.7/termsaverlib</div><div>copying termsaverlib/common.py -&gt; build/lib.linux-i686-2.7/termsaverlib</div><div>copying termsaverlib/exception.py -&gt; build/lib.linux-i686-2.7/termsaverlib</div><div>copying termsaverlib/__init__.py -&gt; build/lib.linux-i686-2.7/termsaverlib</div><div>creating build/lib.linux-i686-2.7/termsaverlib/screen</div><div>copying termsaverlib/screen/programmer.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen</div><div>copying termsaverlib/screen/rssfeed.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen</div><div>copying termsaverlib/screen/rfc.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen</div><div>copying termsaverlib/screen/urlfetcher.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen</div><div>copying termsaverlib/screen/jokes4all.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen</div><div>copying termsaverlib/screen/dot.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen</div><div>copying termsaverlib/screen/__init__.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen</div><div>copying termsaverlib/screen/asciiartfarts.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen</div><div>copying termsaverlib/screen/quotes4all.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen</div><div>copying termsaverlib/screen/randtxt.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen</div><div>creating build/lib.linux-i686-2.7/termsaverlib/screen/base</div><div>copying termsaverlib/screen/base/rssfeed.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen/base</div><div>copying termsaverlib/screen/base/urlfetcher.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen/base</div><div>copying termsaverlib/screen/base/filereader.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen/base</div><div>copying termsaverlib/screen/base/__init__.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen/base</div><div>creating build/lib.linux-i686-2.7/termsaverlib/screen/helper</div><div>copying termsaverlib/screen/helper/position.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen/helper</div><div>copying termsaverlib/screen/helper/urlfetcher.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen/helper</div><div>copying termsaverlib/screen/helper/typing.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen/helper</div><div>copying termsaverlib/screen/helper/xmlreader.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen/helper</div><div>copying termsaverlib/screen/helper/__init__.py -&gt;</div><div>build/lib.linux-i686-2.7/termsaverlib/screen/helper</div><div>running build_scripts</div><div>creating build/scripts-2.7</div><div>copying and adjusting termsaver -&gt; build/scripts-2.7</div><div>changing mode of build/scripts-2.7/termsaver from 644 to 755</div><div>running build_trans</div><div>Compiling locale/ja.po</div><div>Compiling locale/en.po</div><div>running install_lib</div><div>creating /usr/local/lib/python2.7/dist-packages/termsaverlib</div><div>copying build/lib.linux-i686-2.7/termsaverlib/constants.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib</div><div>creating /usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/programmer.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/rssfeed.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/rfc.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/urlfetcher.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/jokes4all.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/dot.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>creating /usr/local/lib/python2.7/dist-packages/termsaverlib/screen/base</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/base/rssfeed.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/base</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/base/urlfetcher.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/base</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/base/filereader.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/base</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/base/__init__.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/base</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/__init__.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/asciiartfarts.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>creating /usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/helper/position.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/helper/urlfetcher.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/helper/typing.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/helper/xmlreader.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/helper/__init__.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/quotes4all.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>copying build/lib.linux-i686-2.7/termsaverlib/screen/randtxt.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen</div><div>copying build/lib.linux-i686-2.7/termsaverlib/i18n.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib</div><div>copying build/lib.linux-i686-2.7/termsaverlib/common.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib</div><div>copying build/lib.linux-i686-2.7/termsaverlib/exception.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib</div><div>copying build/lib.linux-i686-2.7/termsaverlib/__init__.py -&gt;</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/constants.py to</div><div>constants.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/programmer.py to</div><div>programmer.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/rssfeed.py to</div><div>rssfeed.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/rfc.py to rfc.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/urlfetcher.py to</div><div>urlfetcher.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/jokes4all.py to</div><div>jokes4all.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/dot.py to dot.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/base/rssfeed.py</div><div>to rssfeed.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/base/urlfetcher.py</div><div>to urlfetcher.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/base/filereader.py</div><div>to filereader.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/base/__init__.py</div><div>to __init__.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/__init__.py to</div><div>__init__.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/asciiartfarts.py</div><div>to asciiartfarts.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper/position.py</div><div>to position.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper/urlfetcher.py</div><div>to urlfetcher.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper/typing.py</div><div>to typing.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper/xmlreader.py</div><div>to xmlreader.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/helper/__init__.py</div><div>to __init__.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/quotes4all.py to</div><div>quotes4all.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/screen/randtxt.py to</div><div>randtxt.pyc</div><div>byte-compiling /usr/local/lib/python2.7/dist-packages/termsaverlib/i18n.py</div><div>to i18n.pyc</div><div>byte-compiling /usr/local/lib/python2.7/dist-packages/termsaverlib/common.py</div><div>to common.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/exception.py to</div><div>exception.pyc</div><div>byte-compiling</div><div>/usr/local/lib/python2.7/dist-packages/termsaverlib/__init__.py to</div><div>__init__.pyc</div><div>running install_scripts</div><div>copying build/scripts-2.7/termsaver -&gt; /usr/local/bin</div><div>changing mode of /usr/local/bin/termsaver to 755</div><div>running install_egg_info</div><div>Writing /usr/local/lib/python2.7/dist-packages/termsaver-0.1_beta.egg-info</div><div>writing list of installed files to '/tmp/termsaver.install.record.txt'</div><div>Thank you for trying termsaver.</div><div>bruno@development3;~$</div><div><br></div><div><br></div><div>Any help is much appreciated. I found very hard to do anything with</div><div>distutils unless I open the source and see by myself what it can do or</div><div>not... I was hoping there is a better way.</div><div><br></div><div>Thank you in advance,</div></div></blockquote><div><br></div><div>Unfortunately, the install command won't actually run the install_data</div><div>command as a sub-command unless a non-empty list was passed to</div><div>data_files command in setup().</div><div><br></div><div>But I don't think your custom InstallData command is particularly</div><div>necessary.  Try removing InstallData and instead do something like</div><div>this:</div><div><br></div><div>data_files = [(os.path.join('share', 'locale', lang[:-3], 'LC_MESSAGES'),</div><div>                    [os.path.join('build', 'locale', lang[:-3], 'LC_MESSAGES',</div><div>                                       'termsaver.mo')])</div><div>                   for lang in os.listdir('locale')]</div><div><br></div><div>and</div><div><br></div><div>setup(</div><div>...</div><div>data_files=data_files,</div><div>...)</div><div><br></div><div>That should do what you're trying to do.</div><div><br></div><div>Erik</div></div></div></span>
                  
                  
                  
                  
                </div></blockquote><div>
                    <br>
                </div>