Translate: Add additional custom errors#320
Open
markoheijnen wants to merge 1 commit intoWordPress:trunkfrom
Open
Translate: Add additional custom errors#320markoheijnen wants to merge 1 commit intoWordPress:trunkfrom
markoheijnen wants to merge 1 commit intoWordPress:trunkfrom
Conversation
dd32
reviewed
May 20, 2024
Comment on lines
+232
to
+235
| return esc_html__( | ||
| 'Must be ' . $this->array_to_string( self::CONTEXT_ENUM_CHECK_LIST[$gp_original->context] ), | ||
| 'glotpress' | ||
| ); |
Member
There was a problem hiding this comment.
This should be a literal string, given it's being translated:
Suggested change
| return esc_html__( | |
| 'Must be ' . $this->array_to_string( self::CONTEXT_ENUM_CHECK_LIST[$gp_original->context] ), | |
| 'glotpress' | |
| ); | |
| return sptintnt( | |
| esc_html__( | |
| 'Must be one of %s', | |
| 'glotpress' | |
| ), | |
| $this->array_to_string( self::CONTEXT_ENUM_CHECK_LIST[$gp_original->context] ) | |
| ); |
| return true; | ||
| } | ||
| if ( ! str_contains( $gp_original->context, 'timezone date format' ) ) { | ||
| if ( strpos( $gp_original->comment, 'https://www.php.net/manual/datetime.format.php' ) === false ) { |
Member
There was a problem hiding this comment.
This can keep using str_contains() as WordPress has a polyfill for it. Unless you want to do a case-insensitive check then this should be a stripos.
Comment on lines
+23
to
+30
| const CONTEXT_ENUM_CHECK_LIST = [ | ||
| 'text direction' => [ 'ltr', 'rtl' ], | ||
| 'Open Sans font: on or off' => [ 'on', 'off' ], | ||
| 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' => [ 'no-subset', 'greek', 'cyrillic', 'vietnamese' ], | ||
| 'Word count type. Do not translate!' => [ 'characters_excluding_spaces', 'characters_including_spaces', 'words' ], | ||
| 'decline months names: on or off' => [ 'on', 'off' ], | ||
| 'Comment number declension: on or off' => [ 'on', 'off' ], | ||
| ]; |
Member
There was a problem hiding this comment.
These in general follow a specific format, I wonder if we could add something more generic.
Word: ... (option1, option2)= must be option1 or option2Word: option1 or option2= Must be option1 or option2Do not translatein the comment, and neither of the above =Triple check please?
Wouldn't cover 100% of cases, but would help with such strings in the future.
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.
I was talking with @Zodiac1978 and he created https://gist.github.com/Zodiac1978/1d1bd363d5ba7d1ea68e3ffe352008f1. Based on that I updated the plugin with additional checks.
I also updated
is_core_project()so it works for the main project as well.