← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1288049] Re: Lazy translation fails for complex formatting

 

** Also affects: nova
   Importance: Undecided
       Status: New

** Changed in: oslo
     Assignee: (unassigned) => James Carey (jecarey)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1288049

Title:
  Lazy translation fails for complex formatting

Status in OpenStack Compute (Nova):
  New
Status in Oslo - a Library of Common OpenStack Code:
  New

Bug description:
  When lazy translation is enabled _() returns a gettextutils.Message
  instance.   When formatting (%) is called on the instance rather than
  apply the replacement values, it gathers them so they can be applied
  when the message is lazily translated.   This support includes the use
  of keyword replacement as part of formatting (passing a dictionary).
  In order to limit the size of the dictionary, especially in the case
  where locales is passed, the dictionary of values is limited to only
  those keywords that are actually referenced in the format string.

  The code that extracts the replacement keys (and thus dictionary
  entries to keep) only handles simple formatting.  Currently it does
  not handle things like '%(key).02f', but instead omits them from the
  dictionary, which causes a KeyError when the message is translated and
  the replacements applied.

  Confirmed that regex that extracts the keywords does not handle this case: 
  https://github.com/openstack/oslo-incubator/blob/master/openstack/common/gettextutils.py#L266

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1288049/+subscriptions