Repository navigation
feat: declare the text parameters of the attributes in resources/i18n.php - #15
Merged
Merged
Conversation
….php A translation tool reads the file as data, found through extra.pollora.i18n in composer.json. A test fails when an attribute gains a text parameter that is classed neither as translatable nor as technical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A data file,
resources/i18n.php, lists the constructor parameters of the attributes that hold text shown to a person (labels, titles, descriptions, singular and plural names…), andcomposer.jsonannounces it underextra.pollora.i18n.It is plain data: this package does not depend on any translation package, and a tool such as
pollora/i18ncan read the file to know which strings to extract and translate.Drift guard
tests/Unit/I18nDeclarationTest.phpwalks every attribute class ofsrc/(file system and reflection, no hard-coded list) and requires eachstringorarrayconstructor parameter to be either inresources/i18n.phpor in an explicit "technical" list of the test (slugs, keys, hooks, capabilities, formats, callbacks…). A parameter that is in neither makes the test fail and says what to do, so a new text parameter cannot be added without deciding whether it is translated. It also checks that no parameter is classified twice, that no entry points at a parameter that no longer exists, thatcomposer.jsondeclares the file, and that.gitattributesdoes not excluderesources/.Choices worth a look
Ability::labelanddescription,Meta::label,descriptionandgroup,PostType\FeaturedImage::value,Role::label.AdminCols,AdminFilters,Template,Meta::hints): the text inside them is marked where it is written, withnew Translatable('…')frompollora/i18n, rather than declared here.Taxonomy\DefaultTerm(stored in the database at creation) andWpCli\Synopsis(WP-CLI does not translate them).No dependency is added and no signature changes.