from configparser import RawConfigParser
from datetime import datetime
from io import StringIO
-from locale import getpreferredencoding
from babel import __version__ as VERSION
from babel import Locale, localedata
format = u'%%-%ds %%s' % (longest + 1)
for identifier in identifiers:
locale = Locale.parse(identifier)
- output = format % (identifier, locale.english_name)
- print(output.encode(sys.stdout.encoding or
- getpreferredencoding() or
- 'ascii', 'replace'))
+ print(format % (identifier, locale.english_name))
return 0
if not args:
pybabel: error: no valid command or option passed. try the -h/--help option for more information.
""", sys.stderr.getvalue().lower())
+ def test_list_locales(self):
+ """
+ Test the command with the --list-locales arg.
+ """
+ result = self.cli.run(sys.argv + ['--list-locales'])
+ assert not result
+ output = sys.stdout.getvalue()
+ assert 'fr_CH' in output
+ assert 'French (Switzerland)' in output
+ assert "\nb'" not in output # No bytes repr markers in output
+
def _run_init_catalog(self):
i18n_dir = os.path.join(data_dir, 'project', 'i18n')
pot_path = os.path.join(data_dir, 'project', 'i18n', 'messages.pot')