So basically what the message says is that the translator would have difficulties reordering the variables, if he/she needs to. So consider the following:
my_string = "Hello %s, it is %s o'clock." % ('Foo', 'two')
Now assume the translator needs the two
first and the Foo
second:
translated_string = "It is %s o'clock, Mr. %s" % ('Foo', 'two')
Without using format string with named arguments
, the Foo
would still go into the first %s
, thus giving you:
print translated_string
# Output: It is Foo o'clock, Mr. two.
To solve the problem, simply use named arguments
. So the above example would be:
my_string = "Hello %(person)s, it is %(time)s o'clock." % ({
'person':'Foo',
'time':'two'
})
translated_string = "It is %(time)s o'clock, Mr. %(person)s" % ({
'person':'Foo',
'time':'two'
})
This way, the translator can put person
and time
where ever he/she wants. It also gives them an idea, what the variable is about, which they wouldn't know if you used %s
only.
Hope that clarifies things.