custom-post-type-ui icon indicating copy to clipboard operation
custom-post-type-ui copied to clipboard

Add support for secondary placeholders for singular and plural specification in label autofill

Open tw2113 opened this issue 2 years ago • 3 comments

Originally from: https://github.com/WebDevStudios/custom-post-type-ui/issues/920

When translating auto-populated string values, we want to add support for returning either {{singular}} or {{plural}} instead of %s for placeholders. PHP won't throw a fit if no %s placeholder is returned, with the replacement value still provided. It would if the replacement value wasn't provided.

So in our javascript, we need to amend the section linked below, to first check for {{singular}} or {{plural}} first and if either of those exist, replace appropriately OTHERWISE just use what we have now with checking the if ( 'plural' === plurality ) { etc.

Make sure the description/helper text reflects the availability for these placeholders.

https://github.com/WebDevStudios/custom-post-type-ui/blob/1.13.4/src/js/cptui-scripts.js#L259-L274

tw2113 avatar Mar 10 '23 16:03 tw2113

@wiliamjk just to confirm, this is also going to be needed for taxonomies, correct?

tw2113 avatar Mar 10 '23 17:03 tw2113

First pass at this and I think it will probably handle all the needed parts.

custom-post-type-ui-singular-plural.zip

@wiliamjk would love to have you help confirm that this handles everything in a way that satisfies the original issue.

tw2113 avatar Mar 10 '23 17:03 tw2113

@wiliamjk just to confirm, this is also going to be needed for taxonomies, correct?

Yes definitely!

wiliamjk avatar Mar 10 '23 17:03 wiliamjk