Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set default locale for app bundles in OSX Mountain Lion
    primarykey
    data
    text
    <p>How can I set the default locale (LANG, LC_ALL = en_US.UTF-8) with which apps are run in OS X Mountain Lion?</p> <p>I am trying to run a Python program packaged to an .app with py2app. When running the app by double clicking on it the, code segment</p> <pre><code>import locale print locale.getlocale() </code></pre> <p>returns (None,None)</p> <p>However, when running the app from terminal by executing</p> <pre><code>opensesame.app/Contents/MacOS/opensesame </code></pre> <p>the getlocale() function correctly returns (en_US,UTF-8)<br/> (As the terminal has the correct environment settings)</p> <p>I got as far as finding out that apps run in a different environment when double-clicked than when they are run from the terminal, so now I'm trying to set the default encoding variables for apps.</p> <p>I have tried the suggestions I found on: <a href="https://stackoverflow.com/questions/4719789/how-can-you-get-the-system-default-language-locale-in-a-py2app-packaged-python">How can you get the system default language/locale, in a py2app packaged Python app on Mac OS X?</a> and followed the instructions on: <a href="http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPInternational/Articles/ChoosingLocalizations.html" rel="nofollow noreferrer">http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPInternational/Articles/ChoosingLocalizations.html</a></p> <p>I have added both <em>CFBundleLocalizations</em> and <em>LSEnvironment</em> keys to Info.plist (posted below) inside the app bundle, but the getlocale() function keeps returing (None,None)</p> <p>Can anyone tell me to correctly set these variables for OS X apps so that Python picks these up?</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;CFBundleDevelopmentRegion&lt;/key&gt; &lt;string&gt;English&lt;/string&gt; &lt;key&gt;CFBundleDisplayName&lt;/key&gt; &lt;string&gt;opensesame&lt;/string&gt; &lt;key&gt;CFBundleExecutable&lt;/key&gt; &lt;string&gt;opensesame&lt;/string&gt; &lt;key&gt;CFBundleIconFile&lt;/key&gt; &lt;string&gt;opensesame.icns&lt;/string&gt; &lt;key&gt;CFBundleIdentifier&lt;/key&gt; &lt;string&gt;org.pythonmac.unspecified.opensesame&lt;/string&gt; &lt;key&gt;CFBundleInfoDictionaryVersion&lt;/key&gt; &lt;string&gt;6.0&lt;/string&gt; &lt;key&gt;CFBundleName&lt;/key&gt; &lt;string&gt;opensesame&lt;/string&gt; &lt;key&gt;CFBundlePackageType&lt;/key&gt; &lt;string&gt;APPL&lt;/string&gt; &lt;key&gt;CFBundleShortVersionString&lt;/key&gt; &lt;string&gt;0.0.0&lt;/string&gt; &lt;key&gt;CFBundleSignature&lt;/key&gt; &lt;string&gt;????&lt;/string&gt; &lt;key&gt;CFBundleVersion&lt;/key&gt; &lt;string&gt;0.0.0&lt;/string&gt; &lt;key&gt;CFBundleLocalizations&lt;/key&gt; &lt;string&gt;en_US.UTF-8&lt;/string&gt; &lt;key&gt;LSHasLocalizedDisplayName&lt;/key&gt; &lt;false/&gt; &lt;key&gt;NSAppleScriptEnabled&lt;/key&gt; &lt;false/&gt; &lt;key&gt;NSHumanReadableCopyright&lt;/key&gt; &lt;string&gt;Copyright not specified&lt;/string&gt; &lt;key&gt;NSMainNibFile&lt;/key&gt; &lt;string&gt;MainMenu&lt;/string&gt; &lt;key&gt;NSPrincipalClass&lt;/key&gt; &lt;string&gt;NSApplication&lt;/string&gt; &lt;key&gt;LSEnvironment&lt;/key&gt; &lt;dict&gt; &lt;key&gt;LANG&lt;/key&gt; &lt;string&gt;en_US.UTF-8&lt;/string&gt; &lt;key&gt;LC_ALL&lt;/key&gt; &lt;string&gt;en_US.UTF-8&lt;/string&gt; &lt;/dict&gt; &lt;key&gt;PyMainFileNames&lt;/key&gt; &lt;array&gt; &lt;string&gt;__boot__&lt;/string&gt; &lt;/array&gt; &lt;key&gt;PyOptions&lt;/key&gt; &lt;dict&gt; &lt;key&gt;alias&lt;/key&gt; &lt;false/&gt; &lt;key&gt;argv_emulation&lt;/key&gt; &lt;false/&gt; &lt;key&gt;emulate_shell_environment&lt;/key&gt; &lt;false/&gt; &lt;key&gt;no_chdir&lt;/key&gt; &lt;false/&gt; &lt;key&gt;prefer_ppc&lt;/key&gt; &lt;false/&gt; &lt;key&gt;site_packages&lt;/key&gt; &lt;false/&gt; &lt;key&gt;use_pythonpath&lt;/key&gt; &lt;false/&gt; &lt;/dict&gt; &lt;key&gt;PyResourcePackages&lt;/key&gt; &lt;array/&gt; &lt;key&gt;PyRuntimeLocations&lt;/key&gt; &lt;array&gt; &lt;string&gt;@executable_path/../Frameworks/Python.framework/Versions/2.7/Python&lt;/string&gt; &lt;/array&gt; &lt;key&gt;PythonInfoDict&lt;/key&gt; &lt;dict&gt; &lt;key&gt;PythonExecutable&lt;/key&gt; &lt;string&gt;@executable_path/../Frameworks/Python.framework/Versions/2.7/Python&lt;/string&gt; &lt;key&gt;PythonLongVersion&lt;/key&gt; &lt;string&gt;2.7.3 (default, Mar 19 2013, 18:26:22) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)]&lt;/string&gt; &lt;key&gt;PythonShortVersion&lt;/key&gt; &lt;string&gt;2.7&lt;/string&gt; &lt;key&gt;py2app&lt;/key&gt; &lt;dict&gt; &lt;key&gt;alias&lt;/key&gt; &lt;false/&gt; &lt;key&gt;template&lt;/key&gt; &lt;string&gt;app&lt;/string&gt; &lt;key&gt;version&lt;/key&gt; &lt;string&gt;0.7.3&lt;/string&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/plist&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload