WebDevStudios / WebDevStudios/custom-post-type-ui

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

Open
#921 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
641
Forks
139
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/js/cptui-scripts.js around lines 259-274 and trace the label autofill replacement logic for singular and plural values. Update the related description/helper text to mention the {{singular}} and {{plural}} placeholders, then verify that translated labels use those placeholders when present and preserve the existing fallback behavior otherwise.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php, wordpress
Domain
frontend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.