Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hyde gen -r fails with locale.Error: unsupported locale setting #1

Open
sultaniman opened this issue Nov 1, 2012 · 14 comments
Open

Comments

@sultaniman
Copy link

(hyde)ninja trans: hyde gen -r -c site.yaml 
 12:11:35 hyde.engine Reading site configuration from [/Users/sultan/.virtualenvs/hyde/trans/site.yaml]
 12:11:35 hyde Regenerating the site...
 12:11:35 hyde.engine Reading site contents
 12:11:35 hyde.engine Generating site at [/Users/sultan/.virtualenvs/hyde/trans]
 12:11:35 hyde.engine Configuring the template environment
 12:11:35 hyde.engine Generating site to [/Users/sultan/.virtualenvs/hyde/trans/deploy]
Traceback (most recent call last):
  File "/Users/sultan/.virtualenvs/hyde/bin/hyde", line 8, in <module>
    load_entry_point('hyde==0.8.5a15', 'console_scripts', 'hyde')()
  File "/Users/sultan/.virtualenvs/hyde/src/hyde/hyde/main.py", line 10, in main
    Engine().run()
  File "/Users/sultan/.virtualenvs/hyde/src/hyde/hyde/engine.py", line 39, in run
    super(Engine, self).run(args)
  File "/Users/sultan/.virtualenvs/hyde/lib/python2.7/site-packages/commando.py", line 198, in run
    args.run(self, args)
  File "/Users/sultan/.virtualenvs/hyde/src/hyde/hyde/engine.py", line 118, in gen
    gen.generate_all(incremental=incremental)
  File "/Users/sultan/.virtualenvs/hyde/src/hyde/hyde/generator.py", line 205, in generate_all
    self.__generate_node__(self.site.content, incremental)
  File "/Users/sultan/.virtualenvs/hyde/src/hyde/hyde/generator.py", line 303, in __generate_node__
    self.__generate_resource__(resource, incremental)
  File "/Users/sultan/.virtualenvs/hyde/src/hyde/hyde/generator.py", line 324, in __generate_resource__
    self.update_deps(resource)
  File "/Users/sultan/.virtualenvs/hyde/src/hyde/hyde/generator.py", line 144, in update_deps
    deps.extend(self.template.get_dependencies(rel_path))
  File "/Users/sultan/.virtualenvs/hyde/src/hyde/hyde/ext/templates/jinja.py", line 716, in get_dependencies
    text = self.env.loader.get_source(self.env, path)[0]
  File "/Users/sultan/.virtualenvs/hyde/src/hyde/hyde/ext/templates/jinja.py", line 601, in get_source
    contents = self.preprocessor(resource, contents) or contents
  File "/Users/sultan/.virtualenvs/hyde/src/hyde/hyde/plugin.py", line 47, in __call_plugins__
    res = function(*args)
  File "/Users/sultan/.virtualenvs/hyde/trans/local.py", line 60, in begin_text_resource
    (lc, resource.meta.encoding))
  File "/Users/sultan/.virtualenvs/hyde/lib/python2.7/locale.py", line 531, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
@navilan
Copy link
Member

navilan commented Nov 1, 2012

>>> import itertools, locale
>>> list(itertools.ifilter(lambda l: l == 'en' or l == 'ru', locale.locale_alias.keys()))
['en', 'ru']
>>> list(itertools.ifilter(lambda l: l.startswith('en') or l.startswith('ru'), locale.locale_alias.keys()))
[
    'english_united-states', 'en_gb@euro', 'english_us.ascii', 'ru_ua.koi8u', 
    'ru_ua.microsoftcp1251', 'rumanian', 'ru.koi8r', 'en_au', 'en_za.iso88591', 
    'en_hk', 'en_us.885915', 'en_us.iso885915@euro', 'en_sg', 'en_za', 'en_zw', 
    'en_us@euro', 'en_sg.iso88591', 'en_ie', 'en_in', 'ru_ru.koi8r', 'en_ie@euro', 
    'en_be', 'en_bw', 'en_uk', 'en_us', 'en_us@euro@euro', 'ru_ru.cp1251', 
    'en_gb.iso885915', 'eng_gb', 'en_ca', 'en_za@euro', 'russian', 'english_us.8859', 
    'en_hk.iso88591', 'en_gb.88591', 'en_ie.utf8@euro', 'ru_ua.cp1251', 'en_za.iso885915', 
    'eng_gb.8859', 'en_us.iso88591', 'en.iso88591', 'en', 'english.iso88591', 'en_ph.iso88591', 
    'en_ph', 'en_nz.iso88591', 'english_uk', 'english_us', 'en_ca.iso88591', 'ru_ru.microsoftcp1251', 
    'en_us.iso885915', 'en_za.88591', 'english_uk.8859', 'en_ie.iso88591', 'english_united-states.437', 
    'en_us.88591', 'en_zw.iso88591', 'en_gb.iso88591', 'en_ie.iso885915', 'en_gb', 'en_nz', 'english', 
    'en_bw.iso88591', 'ru_ru', 'ru_ua', 'ru_ru.iso88595', 'en_ie.iso885915@euro', 'en_au.iso88591', 
    'en_be@euro', 'ru']

What do you get?

@navilan
Copy link
Member

navilan commented Nov 1, 2012

If you are on ubuntu, you can also try:

apt-get install locales-all

@navilan
Copy link
Member

navilan commented Nov 1, 2012

Anyways, I suspect the problem is you don't have en or ru or both unavailable as independent locales. So one option is for you to change en and ru to en_us and ru_ru everywhere.

@sultaniman
Copy link
Author

I have the same output, I work on OSX here is my ~/.profile file

export LANG="ru_RU.UTF-8"
export LC_COLLATE="ru_RU.UTF-8"
export LC_CTYPE="ru_RU.UTF-8"
export LC_MESSAGES="ru_RU.UTF-8"
export LC_MONETARY="ru_RU.UTF-8"
export LC_NUMERIC="ru_RU.UTF-8"
export LC_TIME="ru_RU.UTF-8"
export LC_ALL= 

@sultaniman
Copy link
Author

I get the same error even if change ru to ru_ru and en to en_us in language and locale settings in *.yaml files

@navilan
Copy link
Member

navilan commented Nov 1, 2012

@sultaniman
Copy link
Author

The same thing, for a while I decided to stay with old configs to provide basic internationalization

@navilan
Copy link
Member

navilan commented Nov 1, 2012

So, after you changed export LC_ALL= to export LC_ALL='en_US' and sourced the profile you still get the same error?

@navilan
Copy link
Member

navilan commented Nov 1, 2012

I meant export LC_ALL='ru_RU'

@sultaniman
Copy link
Author

Yes I've the same error, though I've a lot of other Django projects and they work just fine.

@navilan
Copy link
Member

navilan commented Nov 1, 2012

hmm. I am really not sure what the issue is then.

(M=3f8fe) [trans] [email protected] ~/work/hyde/source/trans> locale >> o
(M=3f8fe o) [trans] [email protected] ~/work/hyde/source/trans> hyde gen -r >> o
(M=3f8fe o) [trans] [email protected] ~/work/hyde/source/trans> lssitepackages >> o
(M=3f8fe o) [trans] [email protected] ~/work/hyde/source/trans> cat o
LANG="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_CTYPE="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_ALL="ru_RU.UTF-8"
 14:47:59 hyde.engine Reading site configuration from [/Users/lakshmivyas/work/hyde/source/trans/site.yaml]
 14:47:59 hyde Regenerating the site...
 14:47:59 hyde.engine Reading site contents
 14:47:59 hyde.engine Generating site at [/Users/lakshmivyas/work/hyde/source/trans]
 14:47:59 hyde.engine Configuring the template environment
 14:47:59 hyde.engine Generating site to [/Users/lakshmivyas/work/hyde/source/trans/deploy]
 14:48:01 hyde Generation complete.
Babel-0.9.6-py2.7.egg-info
Jinja2-2.6-py2.7.egg-info
Markdown-2.2.0-py2.7.egg-info
Markdown.egg-link
PyYAML-3.10-py2.7.egg-info
Pygments-1.5-py2.7.egg-info
argparse-1.2.1-py2.7.egg-info
argparse.py
argparse.pyc
babel
commando-0.1.2a-py2.7.egg-info
commando.py
commando.pyc
cssselect
cssselect-0.7.1-py2.7.egg-info
distribute-0.6.14-py2.7.egg
easy-install.pth
hyde.egg-link
jinja2
lxml
lxml-3.0.1-py2.7.egg-info
markdown
pip-1.2.1-py2.7.egg
pygments
pyquery
pyquery-1.2.1-py2.7.egg-info
setuptools-0.6c11-py2.7.egg
setuptools.pth
smartypants-1.6.0.3-py2.7.egg-info
smartypants.py
smartypants.pyc
typogrify-hyde.egg-link

@wearpants
Copy link

On ubuntu 12.04, I needed to apt get install language-pack-ru and then it worked fine.

what does locale -a |grep ru in an OS X terminal show?

@wearpants
Copy link

Playing in a python shell, it seems using a tuple for 2nd arg to setlocale breaks on OS X (10.6.8) system python (2.6.1). Calling locale.setlocale(locale.LC_ALL, 'ru_RU.UTF-8') works correctly (on linux too).

@sultaniman
Copy link
Author

I've fixed this error here is the fixes, just added some conditional statements

def begin_text_resource(self, resource, text):
        try:
            lc = resource.meta.lc
            self.default_locale = locale.getlocale()

            if 'darwin' in sys.platform:
                locale.setlocale(locale.LC_ALL, lc)
            elif 'linux' in sys.platform:
                locale.setlocale(locale.LC_ALL, (lc, resource.meta.encoding))

            self.template.env.install_gettext_translations(self.translations[lc], newstyle=True)
        except AttributeError:
            pass

        return text

And now I have the error like

Traceback (most recent call last):
  File "/Users/sultan/.virtualenvs/e/bin/hyde", line 8, in <module>
    load_entry_point('hyde==0.8.5a15', 'console_scripts', 'hyde')()
  File "/Users/sultan/.virtualenvs/e/src/hyde/hyde/main.py", line 10, in main
    Engine().run()
  File "/Users/sultan/.virtualenvs/e/src/hyde/hyde/engine.py", line 39, in run
    super(Engine, self).run(args)
  File "/Users/sultan/.virtualenvs/e/lib/python2.7/site-packages/commando.py", line 198, in run
    args.run(self, args)
  File "/Users/sultan/.virtualenvs/e/src/hyde/hyde/engine.py", line 118, in gen
    gen.generate_all(incremental=incremental)
  File "/Users/sultan/.virtualenvs/e/src/hyde/hyde/generator.py", line 205, in generate_all
    self.__generate_node__(self.site.content, incremental)
  File "/Users/sultan/.virtualenvs/e/src/hyde/hyde/generator.py", line 303, in __generate_node__
    self.__generate_resource__(resource, incremental)
  File "/Users/sultan/.virtualenvs/e/src/hyde/hyde/generator.py", line 324, in __generate_resource__
    self.update_deps(resource)
  File "/Users/sultan/.virtualenvs/e/src/hyde/hyde/generator.py", line 148, in update_deps
    self.deps[rel_path] = deps
  File "/Users/sultan/.virtualenvs/e/bin/../lib/python2.7/UserDict.py", line 24, in __setitem__
    def __setitem__(self, key, item): self.data[key] = item
TypeError: 'NoneType' object does not support item assignment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants