Coder Social home page Coder Social logo

Comments (6)

Cimbali avatar Cimbali commented on August 17, 2024

Yeah some of the locale things are not really done in a portable way (there is already a special case for windows...). I don't have a Mac myself so I can't really test regularly, I might have broken something inadvertently.

Basically the problem here is that Gtk relies on the locale domain being set in the C gettext library, which the gettext module doesn't do -- which is why we do it through the locale module, which exposes the C gettext library's functions directly. A binding that doesn't work on your platform apparently.

The standard Python feature as you say, would be to do bind the text domain with the gettext module, but this results in only half the strings being translated (those dynamically used from the python code, but not those loaded by the Gtk widgets).

Let me go look for a workaround.

from pympress.

Cimbali avatar Cimbali commented on August 17, 2024

@brianmay Is there a libintl.dylib ou your system? Does importing that in python with cdll allow to call bindtextdomain? something like:

import ctypes
lib = ctypes.cdll.LoadLibrary('libintl.dylib')
lib.bindtextdomain('test', '/usr/share/locale/')

from pympress.

brianmay avatar brianmay commented on August 17, 2024
>>> import ctypes
>>> lib = ctypes.cdll.LoadLibrary('libintl.dylib')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/brianmay/.pyenv/versions/2.7.13/lib/python2.7/ctypes/__init__.py", line 440, in LoadLibrary
    return self._dlltype(name)
  File "/Users/brianmay/.pyenv/versions/2.7.13/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libintl.dylib, 6): image not found

Looks like on my system I have a /usr/local/Cellar/gettext/0.19.8.1/lib/libintl.dylib.

Ok, this helps.

export LD_LIBRARY_PATH=/usr/local/Cellar/gettext/0.19.8.1/lib/

Now:

>>> import ctypes
>>> lib = ctypes.cdll.LoadLibrary('libintl.dylib')
>>> lib.bindtextdomain('test', '/usr/share/locale/')
1490168128

Ok, that looks better so far. Will try pympress again.

from pympress.

brianmay avatar brianmay commented on August 17, 2024

pympress still generates the same error.

from pympress.

Cimbali avatar Cimbali commented on August 17, 2024

If you check out the fix-osx-i18n branch, this should be fixed (not crash anymore).
You can do this with (adding you favourite options, and maybe --upgrade and --force-reinstall)

pip install git+https://github.com/Cimbali/pympress.git@fix-osx-i18n

What's more, if libintl.dylib is in your library path and you set LANG to de_DE.utf-8 or fr_FR.utf-8, pympress should run in German or French respectively.

from pympress.

brianmay avatar brianmay commented on August 17, 2024

It works!

Thanks for your help.

from pympress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.