i18n: add new APIs for React bindings#28784
Merged
Merged
Conversation
|
Size Change: +281 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
sirreal
approved these changes
Feb 5, 2021
Member
sirreal
left a comment
There was a problem hiding this comment.
One question, otherwise this looks good to me. Thanks for breaking it out 👍
| * Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`, | ||
| * `i18n.gettext_domain` or `i18n.ngettext_with_context` | ||
| */ | ||
| const I18N_HOOK_REGEXP = /^i18n\.(n?)gettext(_|$)/; |
Member
There was a problem hiding this comment.
Does this need to match i18n.has_translation as well?
Member
Author
There was a problem hiding this comment.
Good point 🙂 When I was adding this regexp and the code that uses it, the i18n.has_translation filter didn't exist yet. The filter cannot change the result of __(), but it can change result of hasTranslation() which is one of the functions that the React bindings expose. I'll add it.
Contributor
|
Not sure I can really review as such, but this certainly doesn't break anything I'm doing. So 👍 from me. |
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.
Spinoff from #28465 that adds several new APIs to
@wordpress/i18n, with documentations and tests:defaultI18nexport that exports the defaultI18ninstance, in addition to already existing one-by-one method exportsgetLocaleDatato retrieve the internal Tannin structure. Counterpart to existingsetLocaleDatahasTranslationto check if a given translation exists. Customizable with thehas_translationfiltersubscribeto subscribe to updates whensetLocaleDatais called or hooks added or removed -- anything that makes a__( ... )translation call return a different resultDetails were already discussed in #28465. Cc @leewillis77 for review.