Jump to content

What is [1]%d[/1] in a translatable string?


kcpau

Recommended Posts

In the blockcart module translation there is this string :

 

There are [1]%d[/1] items in your cart.

 

The Simplified Chinese translation that comes with the system only has %d without the [1]..[/1].  As a result, when there are two or more items in the cart, the Simplified Chinese version shows 0 items.  When I added back the [1]..[/1], the display is correct.

 

I could not find the [1]..[/1] notation mentioned in any documentation.  I thought the %d is sufficient.  Can someone tell me what they are for?

Link to comment
Share on other sites

There are instructions at the top of the page when editing translations in the Back Office:

 

 

Some of these expressions use this special syntax: %d.
You MUST use this syntax in your translations. Here are several examples

  • "There are %d products": "%d" will be replaced by a number.
  • "List of pages in %s": "%s" will be replaced by a string.
  • "Feature: %1$s (%2$d values)": The numbers enable you to reorder the variables when necessary.
Link to comment
Share on other sites

But the [1]..[/1] notation is not described in the instruction.  is [1]%d[/1] the same as %1$d?  If that is the case, the string

 

There are [1]%d[/1] items in your cart.

 

only has one value to substitute, why does it need to have the position specified??

 

Thanks

Link to comment
Share on other sites

I have no idea. I've never heard of that notation before. You can remove it and just use %d.

I'm afraid, no, you cannot!

If you remove it, the variable won't be replaced - lIke in the wrong Chinese translation the user mentioned. It indicates a tag, often replaced by a link, and you have to keep it. For more informations please have a look at the Crowdin translators instructions.

Link to comment
Share on other sites

Just another example without a numeric placeholder:

Please make sure you\'ve chosen a [1]payment method[/1] and accepted the [2]terms and conditions[/2].

At runtime this will be replaced for the customer with links to the payment methods' page or the terms of trade.
 
Other examples:

Not you? [1]Log out[/1]
You can also [1]download your invoice[/1]
To disable it, go to[1]Product Settings[/1]

Hopefully it becomes clearer now for you.
 
However, the questioned translation item seems to be outdated in any case. The current wording is:

There are %products_count% items in your cart.

The PrestaShop developers are unbeatable in creating new translation items with every new release. :D

 

Link to comment
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...