1

I have this python line

raise ValueError(_(u'Your password must be {} of characters or longer.'.format(MIN_PASSWORD_LENGTH)))

I added it to the PO file:

msgid "Your password must be {} of characters or longer."
msgstr "Votre mot de passe doit être {} de caractères ou plus."

I compiled it but it doesn't translate it.

All other translations work on this site except this one.

What am I missing here?

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Felix
  • 25
  • 8

2 Answers2

1

On the .po file you need to keep the %s format.

like this:

msgid "Your password must be %s characters or longer."
msgstr "Votre mot de passe doit être %s caractères ou plus."

Or with the python-brace-format

#: foo/bar.py:32 
#, python-brace-format
msgid "Your password must be {n} characters or longer."
msgstr "Votre mot de passe doit être {n} caractères ou plus."
oCcSking
  • 888
  • 21
  • 43
0
raise ValueError("Your password must be " +str(MIN_PASSWORD_LENGTH)+" of characters or longer")


raise ValueError(u'Your password must be {} of characters or longer.'.format(MIN_PASSWORD_LENGTH))

i just removed one _ because i don't think it was needed.

enter image description here

Jainil Patel
  • 1,284
  • 7
  • 16
  • 1
    At least at some words to your answer explaining what the problem was and what you did – Sheldore Jun 10 '19 at 14:35
  • Whatever you did, write it in the answer. Otherwise, readers will have to compare the codes character by character – Sheldore Jun 10 '19 at 15:34
  • @JainilPatel changed to raise ValueError(u'Your password must be {} of characters or longer.'.format(MIN_PASSWORD_LENGTH)) and still it doesn't work. – Felix Jun 10 '19 at 17:18
  • @JainilPatel if I change to your first proposal what should I write at the po file? "raise ValueError("Your password must be " +str(MIN_PASSWORD_LENGTH)+" of characters or longer")" – Felix Jun 10 '19 at 17:19
  • @JainilPatel po is the translation file see https://docs.ckan.org/en/2.8/extensions/translating-extensions.html. my question was about the translation, I have no problem with displaying it in English – Felix Jun 10 '19 at 17:56
  • @JainilPatel to other language, in this example Hebrew – Felix Jun 11 '19 at 07:54
  • @JainilPatel whatever language, it doesn't matter. see docs.ckan.org/en/2.8/extensions/translating-extensions.html – Felix Jun 11 '19 at 13:19
  • @JainilPatel msgid "Your password must be {} of characters or longer." msgstr "הסיסמה חייבת להכיל מינימום {} תווים" – Felix Jun 12 '19 at 07:21
  • str("Your password must be " +str(MIN_PASSWORD_LENGTH)+" of characters or longer") – Jainil Patel Jun 12 '19 at 07:27
  • @JainilPatel I don't understand what do you mean. What should I write in the po file? – Felix Jun 12 '19 at 09:26