90060722a9
This patch introduces a new directory layout in doc/source in conformance with the OpenStack manuals project migration spec [1], moves the existing content in manila/doc/source into the new directories, and adjusts index files accordingly. This is the first step in the migration process as outlined in the spec. [1] https://specs.openstack.org/openstack/docs-specs/specs/pike/os-manuals-migration.html Partial-Bug: #1706181 Needed-By: I7924d94b82e7c8d9716bad7a219fc38c57970773 Depends-On: Ifc80fc56648cef74c85464321d1850e8c68449a0 Depends-On: Ia750cb049c0f53a234ea70ce1f2bbbb7a2aa9454 Change-Id: Ieea33262101a1d2459492c1c8aaac5fe042279f6
37 lines
1.5 KiB
ReStructuredText
37 lines
1.5 KiB
ReStructuredText
Internationalization
|
|
====================
|
|
Manila uses `gettext <http://docs.python.org/library/gettext.html>`_ so that
|
|
user-facing strings appear in the appropriate language in different locales.
|
|
|
|
Beginning with the Pike series, OpenStack no longer supports log translation.
|
|
It is not useful to add translation instructions to new code, and the
|
|
instructions can be removed from old code.
|
|
|
|
Other user-facing strings, e.g. in exception messages, should be translated.
|
|
|
|
To use gettext, make sure that the strings passed to the logger are wrapped
|
|
in a ``_()`` function call. For example::
|
|
|
|
msg = _("Share group %s not found.") % share_group_id
|
|
raise exc.HTTPNotFound(explanation=msg)
|
|
|
|
Do not use ``locals()`` for formatting messages because:
|
|
1. It is not as clear as using explicit dicts.
|
|
2. It could produce hidden errors during refactoring.
|
|
3. Changing the name of a variable causes a change in the message.
|
|
4. It creates a lot of otherwise unused variables.
|
|
|
|
If you do not follow the project conventions, your code may cause the
|
|
LocalizationTestCase.test_multiple_positional_format_placeholders test to fail
|
|
in manila/tests/test_localization.py.
|
|
|
|
The ``_()`` function is brought into the global scope by doing::
|
|
|
|
from manila.openstack.common import gettextutils
|
|
gettextutils.install("manila")
|
|
|
|
These lines are needed in any toplevel script before any manila modules are
|
|
imported. If this code is missing, it may result in an error that looks like::
|
|
|
|
NameError: name '_' is not defined
|