Skip to content

Commit b8d6cee

Browse files
stevemarDean Troyer
authored andcommitted
document locale and language support tips
We have full support for various locales and languages, but often there are hiccups when setting up a terminal to use OSC in this manner. Document a few common questions so we don't have to individually support each bug report. Change-Id: I0f7c7efce3a2c00cc82ed8c67310e027b5e45a45
1 parent 756d2fa commit b8d6cee

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

doc/source/configuration.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,59 @@ The logging level for `--log-file` can be set by using following options.
214214
* `-v, --verbose`
215215
* `-q, --quiet`
216216
* `--debug`
217+
218+
Locale and Language Support
219+
---------------------------
220+
221+
Full support for languages is included as of OpenStackClient 3.0.0. Here are a
222+
few tips to ensure you have a correct configuration.
223+
224+
Verify preferred python encoding
225+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
226+
227+
Please perform the following to diagnose ensure locale settings are correct.
228+
Run python interactively and print the preferred encoding value, e.g.:
229+
230+
::
231+
232+
$ python -c "import locale; print locale.getpreferredencoding()"
233+
234+
If the value is ``ascii`` or ``ANSI_X3.4-1968`` or any other equivalent name for
235+
ASCII the problem is in your environment. You most likely do not have your LANG
236+
environment variable set correctly.
237+
238+
Check the LANG environment variable
239+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
240+
241+
``LANG`` should be of the form: `lang_code`_`[region_code]`.`encoding`.
242+
For example, it may look like: ``en_US.UTF-8``
243+
244+
The critical part here is the `encoding` value of ``UTF-8``. Python will look
245+
up locale information and if it finds an encoding value, it will set the
246+
encoding property of stdin, stdout and stderr to the value found in your
247+
environment, if it's not defined in your environment it defaults to ASCII.
248+
249+
Redirecting output
250+
~~~~~~~~~~~~~~~~~~
251+
252+
The above only occurs if stdin, stdout and stderr are attached to a TTY. If
253+
redirecting data the encoding on these streams will default to the default
254+
encoding which is set in the `site.py` of your Python distribution, which
255+
defaults to ASCII. A workaround for this is to set ``PYTHONIOENCODING`` to UTF8.
256+
257+
::
258+
259+
$ PYTHONIOENCODING=utf-8
260+
261+
A final note about DevStack
262+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
263+
264+
A common post devstack operation is to source the ``openrc`` file to set up
265+
environment variables. Doing so will unset the default ``LANG`` environment
266+
variable in your terminal, which will cause the preferred python encoding to
267+
be ``ascii``. We recommend either setting these environment variables
268+
independently or using the ``devstack`` or ``devstack-admin`` os-cloud profile.
269+
270+
::
271+
272+
$ openstack project list --os-cloud devstack-admin

0 commit comments

Comments
 (0)