Prestashop: You must specify as many arguments (%d, %s ...) as the original string.

Created on 29 Oct 2019  ·  5Comments  ·  Source: PrestaShop/PrestaShop

prestashop 1.7.6.1

when i translation some with %string%,can not save and log this error:

translation:
The password must be at least %length% characters long.
to:
密码长度不能少于%length%个字符

1.7.5.2 1.7.6.1 1.7.6.3 BO Bug Minor To Do Translations

Most helpful comment

(Continuing from discussion in #16421)

@khouloudbelguith After taking a closer look at this I don't think it's a 5 minute fix.

According to TranslateCore::checkAndReplaceArgs() the legacy strings are substituted with strtr instead of vsprintf, so it makes little sense to apply a PassVsprintf constraint to them.

Unfortunately, the way TranslateCore checks which type of string it is is to... Just do the vsprintf regex and see if it's a match.

So if we want to avoid applying a PassVsprintf constraint to legacy strings the whole thing would boil down to "If it matches, check it again. If it doesn't match, ignore"

We could change PassVsprintfValidator to check that both string types match and have different paths to check the string types, but I'm not sure what design considerations there would be there. I'm going to change #16359 to only refer to the other bug for now.

All 5 comments

Hi @langziyang,

Thanks for your report.
I manage to reproduce the issue with PS1.7.6.1 & PS1.7.5.2 in the back.
In the FO, it is OK.
Steps to reproduce the issue

  1. Add the Japan language
  2. Edit the language of the employee to Japan
  3. Try to create a new employee with an invalid password for example 1234
  4. an error is displayed This field cannot be shorter than 8 characters
    image
  5. Go to the BO => International => Translations => edit the Back office with the Japan language
  6. search for this expression "This field cannot be shorter than %limit% characters"
  7. Try to translate it "密码长度不能少于%length%个字符"
  8. Save => a green alert is displayed: Translations successfully updated
    image
  9. Try to reload the page, this expression cannot be saved
  10. you can check in the employee page => the translation is not changed

PS: I tried with the FO => OK
image
image

I’ll add this to the debug roadmap so that it’s fixed. If you have already fixed it on your end or if you think you can do it, please do send us a pull request!
Thanks!

(Continuing from discussion in #16421)

@khouloudbelguith After taking a closer look at this I don't think it's a 5 minute fix.

According to TranslateCore::checkAndReplaceArgs() the legacy strings are substituted with strtr instead of vsprintf, so it makes little sense to apply a PassVsprintf constraint to them.

Unfortunately, the way TranslateCore checks which type of string it is is to... Just do the vsprintf regex and see if it's a match.

So if we want to avoid applying a PassVsprintf constraint to legacy strings the whole thing would boil down to "If it matches, check it again. If it doesn't match, ignore"

We could change PassVsprintfValidator to check that both string types match and have different paths to check the string types, but I'm not sure what design considerations there would be there. I'm going to change #16359 to only refer to the other bug for now.

@khouloudbelguith please add 1.7.6.3 too cause of same issue :-(

Any news ?

Hi @Gipielle,

Sorry, not yet.
But PrestaShop is an open source project, so it can be solved before if someone submits a pull request to solve it.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings