affectiosus Posted October 5, 2012 Share Posted October 5, 2012 What is the usage of "%d" and "%s" variables? I cannot find any answer in web except "do not remove...", but need it because of adapting translation. Thx for help. Link to comment Share on other sites More sharing options...
tomerg3 Posted October 5, 2012 Share Posted October 5, 2012 Where do you see them? Link to comment Share on other sites More sharing options...
affectiosus Posted October 6, 2012 Author Share Posted October 6, 2012 (edited) For example, in some strings like "There is %d products" etc. I don't know, how should I correctly translate it to my language because don't know how PrestaShop processes these variables (%d, %s, %1$s, %2$d and so on). Edited October 6, 2012 by affectiosus (see edit history) Link to comment Share on other sites More sharing options...
phrasespot Posted October 6, 2012 Share Posted October 6, 2012 (edited) They are v1.5 translation dynamic data place holders, modeled after PHP's sprintf. Where you see d an integer is expected and s, a string. The "%d" and "%s" you see will be dynamically populated during the output of the expression, so do not remove them from the translation. Changing their position within the translated expression is OK. E.g. "there are %d items in the cart" => "pu'chaj buSlaH ngotlhwI %d'; translated into Klingon. Read to be translated expression as if it contains a number and then replace that number with %d in translated expression. Likewise for 's' Edited October 6, 2012 by phrasespot (see edit history) 1 Link to comment Share on other sites More sharing options...
affectiosus Posted October 6, 2012 Author Share Posted October 6, 2012 They are v1.5 translation dynamic data place holders, modeled after PHPs sprintf. Where you see d an integer is expected and s, a string. The "%d" and "%s" you see will be dynamically populated during the output of the expression, so do not remove them from the translation. Changing their position within the translated expression is OK. E.g. "there are %d items in the cart" => "pu'chaj buSlaH ngotlhwI %d'; translated into Klingon So, if I understand you correctly, %d used for integer number and %s for any string? And what is %1$s? Link to comment Share on other sites More sharing options...
phrasespot Posted October 6, 2012 Share Posted October 6, 2012 (edited) Argument swapping/position specifier. But at least have the courtesy of looking at the documentation link I posted before asking another question. It is all explained there in detail. %1$s is the first place holder that is a string. %2$s, the second and so on. There is more to it. It will be to your benefit to read the documentation. Edited October 6, 2012 by phrasespot (see edit history) 1 Link to comment Share on other sites More sharing options...
affectiosus Posted October 6, 2012 Author Share Posted October 6, 2012 Ok, thank you, I'll read. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now