-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add Locale::getDisplayKeyword() and Locale::getDisplayKeywordValue() #22264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cb244e3
Add Locale::getDisplayKeyword() and Locale::getDisplayKeywordValue()
LamentXU123 2b0d787
fix CI
LamentXU123 a3097f1
fix stub
LamentXU123 9a9348e
remove @tentative-return-type
LamentXU123 37d515e
fix stub
LamentXU123 053f749
again, fix stubs
LamentXU123 1ab6deb
fix stub
LamentXU123 247501e
add back @tentative-return-type
LamentXU123 0340d9c
increase test coverage
LamentXU123 28f8b6b
use regexes in tests
LamentXU123 6053116
use a better subset for regex
LamentXU123 793bc58
use keywords in regexes
LamentXU123 70383dc
escape bool(true)
LamentXU123 dcc5543
[skip ci] Add NEWS and UPGRADING
LamentXU123 42e5f8c
Merge branch 'master' into implement-RFC-intl
LamentXU123 4632f47
[skip ci] Update NEWS with Intl improvements and fixes
LamentXU123 df63024
[skip ci] Clarify addition of Locale display keyword functions
LamentXU123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| --TEST-- | ||
| locale_get_display_keyword() basic | ||
| --EXTENSIONS-- | ||
| intl | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| function ut_main() | ||
| { | ||
| $default = ut_loc_get_default(); | ||
| ut_loc_set_default('en'); | ||
|
|
||
| $keyword = ut_loc_get_display_keyword('calendar', 'en'); | ||
| var_dump($keyword); | ||
| var_dump(ut_loc_get_display_keyword('calendar', null) === $keyword); | ||
|
|
||
| $keywordValue = ut_loc_get_display_keyword_value('de_DE@calendar=gregorian', 'calendar', 'en'); | ||
| var_dump($keywordValue); | ||
| var_dump(ut_loc_get_display_keyword_value('de_DE@calendar=gregorian', 'calendar', null) === $keywordValue); | ||
|
|
||
| $collationValue = ut_loc_get_display_keyword_value('de_DE@collation=phonebook', 'collation', 'en'); | ||
| var_dump($collationValue); | ||
|
|
||
| ut_loc_set_default($default); | ||
| } | ||
|
|
||
| include_once 'ut_common.inc'; | ||
| ut_run(); | ||
| ?> | ||
| --EXPECTREGEX-- | ||
| string\([1-9][0-9]*\) "[A-Za-z ]*Calendar[A-Za-z ]*" | ||
| bool\(true\) | ||
| string\([1-9][0-9]*\) "[A-Za-z ]*Gregorian[A-Za-z ]*" | ||
| bool\(true\) | ||
| string\([1-9][0-9]*\) "[A-Za-z ]*Phonebook[A-Za-z ]*" | ||
| string\([1-9][0-9]*\) "[A-Za-z ]*Calendar[A-Za-z ]*" | ||
| bool\(true\) | ||
| string\([1-9][0-9]*\) "[A-Za-z ]*Gregorian[A-Za-z ]*" | ||
| bool\(true\) | ||
| string\([1-9][0-9]*\) "[A-Za-z ]*Phonebook[A-Za-z ]*" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --TEST-- | ||
| locale_get_display_keyword_value() error path | ||
| --EXTENSIONS-- | ||
| intl | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $locale = str_repeat('*', 256); | ||
|
|
||
| var_dump(Locale::getDisplayKeywordValue($locale, 'calendar', 'en')); | ||
| var_dump(intl_get_error_message()); | ||
| var_dump(locale_get_display_keyword_value($locale, 'calendar', 'en')); | ||
| var_dump(intl_get_error_message()); | ||
|
|
||
| ?> | ||
| --EXPECT-- | ||
| bool(false) | ||
| string(73) "Locale::getDisplayKeywordValue(): name too long: U_ILLEGAL_ARGUMENT_ERROR" | ||
| bool(false) | ||
| string(75) "locale_get_display_keyword_value(): name too long: U_ILLEGAL_ARGUMENT_ERROR" |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
loc_nameis bounded butkeyword_nameis not, in either branch. Unlike the locale-name overflow (bug 67397),uloc_getDisplayKeyword{,Value}grows the output buffer in the loop and echoes unknown keywords back, so I do not think an overlong keyword can crash. Noting it for symmetry; fine to leave as-is.