getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.58k stars 443 forks source link

ERROR: Failure: Error (unsupported locale setting) #875

Closed da2x closed 10 years ago

da2x commented 10 years ago
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/d/Utvikling/nikola/tests/test_locale.py", line 15, in <module>
    LocaleSupportInTesting.initialize_locales_for_testing('bilingual')
  File "/home/d/Utvikling/nikola/tests/base.py", line 164, in initialize_locales_for_testing
    nikola.utils.LocaleBorg.initialize(locales, default_lang)
  File "/home/d/Utvikling/nikola/nikola/utils.py", line 690, in initialize
    locale.setlocale(locale.LC_ALL, locales[lang])
  File "/usr/lib/python2.7/locale.py", line 547, in setlocale
    return _setlocale(category, locale)
Error: unsupported locale setting
Kwpolska commented 10 years ago

show us the output of locale. Also, does this happen outside of tests, in “real” Nikola?

ccanepa commented 10 years ago

The test suite needs two languajes actually supported by your OS + python. You can specify which languages to use with the environment variables NIKOLA_LOCALE_DEFAULT NIKOLA_LOCALE_OTHER

The first specify the default lang and his locale, the second specifies an aditional lang and locale.

An example of value (assuming the targeted host have suport for locale de_DE de, de_DE.utf8

Look at the docsting in tests/base.py/LocaleSupportInTesting for details.

On Fri, Oct 25, 2013 at 3:42 PM, Daniel Aleksandersen < notifications@github.com> wrote:

Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/nose/loader.py", line 413, in loadTestsFromName addr.filename, addr.module) File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath return self.importFromDir(dir_path, fqname) File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir mod = load_module(part_fqname, fh, filename, desc) File "/home/d/Utvikling/nikola/tests/test_locale.py", line 15, in LocaleSupportInTesting.initialize_locales_for_testing('bilingual') File "/home/d/Utvikling/nikola/tests/base.py", line 164, in initialize_locales_for_testing nikola.utils.LocaleBorg.initialize(locales, default_lang) File "/home/d/Utvikling/nikola/nikola/utils.py", line 690, in initialize locale.setlocale(locale.LC_ALL, locales[lang]) File "/usr/lib/python2.7/locale.py", line 547, in setlocale return _setlocale(category, locale) Error: unsupported locale setting

— Reply to this email directly or view it on GitHubhttps://github.com/getnikola/nikola/issues/875 .

da2x commented 10 years ago

There should be a README in tests/ :-)

Only happens when running tests.

$ locale LANG=nb_NO.UTF-8 LANGUAGE=nb_NO:nb:no_NO:no:nn_NO:nn:en LC_CTYPE="nb_NO.UTF-8" LC_NUMERIC="nb_NO.UTF-8" LC_TIME="nb_NO.UTF-8" LC_COLLATE="nb_NO.UTF-8" LC_MONETARY="nb_NO.UTF-8" LC_MESSAGES="nb_NO.UTF-8" LC_PAPER="nb_NO.UTF-8" LC_NAME="nb_NO.UTF-8" LC_ADDRESS="nb_NO.UTF-8" LC_TELEPHONE="nb_NO.UTF-8" LC_MEASUREMENT="nb_NO.UTF-8" LC_IDENTIFICATION="nb_NO.UTF-8" LC_ALL=

ccanepa commented 10 years ago

About a additional info about tests. we can add a tests/readme.. What do you think @ralsina , @Kwpolska ?

@Aeyoun , what language{s) are you using in nikola ? ( 'en', 'es', ....)

da2x commented 10 years ago

@ccanepa, English only. Guess that is why I only see this when running tests.

ccanepa commented 10 years ago

Ok, you have a Norwegian locale as your preferred locale, so probably python can see it. And you post in English and see no anomalies, so some english locale should also be available. (but it is possible that nikola sees the locale for 'en' as unavailable and the fallback to the 'C' locale, in that case you should see a warning at the start of nikola build)

To be totally certain about what your python thinks it is available you can open a python console and try

import locale
#  for Norwegian
locale.setlocale(locale.LC_ALL, 'nb_NO.utf8')
# for english
locale.setlocale(locale.LC_ALL, 'en.utf8')

(if the later fail you can try with 'en_US.utf8' )

Assuming that worked ok, that is no traceback, you can run the tests by

´´´ export NIKOLA_LOCALE_DEFAULT=en,en.utf8 export NIKOLA_LOCALE_OTHER=es,nb_NO.utf8 nosetests ´´´

The last line instructs nikola to use 'es' as a secondary language, and for that language to use the nb_NO.utf8 locale, which will be enough for testing.

Kwpolska commented 10 years ago

Adding a README for tests is a good idea. I’ll work on it right now.

PS. @Aeyoun, we’d love to see a translation of Nikola to Norwegian! It won’t take you longer than a minute.

Kwpolska commented 10 years ago

reopened, because @Aeyoun should give some feedback.

And I want some feedback on the tests README.

da2x commented 10 years ago

I made one correction ab7d42d, and one addition f80478b. The instructions were clear. I’ll add it to /CONTRIBUTING.rst to encourage more use of the tests.