88 * @param string $message The message being translated
99 * @return string Translated string if one is found in the translation table, or the submitted message if not found
1010 */
11- function pgettext ($ context , $ message )
11+ function pgettext (string $ context , string $ message ): string
1212 {
13- $ context_message = "{ $ context} \004{ $ message} " ;
13+ $ context_message = "$ context \004$ message " ;
1414
1515 $ translation = gettext ($ context_message );
1616
@@ -34,15 +34,15 @@ function pgettext($context, $message)
3434 * @param int $number The number (e.g. item count) to determine the translation for the respective grammatical number
3535 * @return string Correct plural form of message identified by $singular and $plural for $number
3636 */
37- function npgettext ($ context , $ singular , $ plural , $ number )
37+ function npgettext (string $ context , string $ singular , string $ plural , int $ number ): string
3838 {
39- $ context_singular = "{ $ context} \004{ $ singular} " ;
40- $ context_plural = "{ $ context} \004{ $ plural} " ;
39+ $ context_singular = "$ context \004$ singular " ;
40+ $ context_plural = "$ context \004$ plural " ;
4141
4242 $ translation = ngettext ($ context_singular , $ context_plural , $ number );
4343
4444 // If the translation was not found...
45- if ($ translation === $ context_singular or $ translation === $ context_plural ) {
45+ if ($ translation === $ context_singular || $ translation === $ context_plural ) {
4646 // Use native function to return the appropriate string
4747 return ngettext ($ singular , $ plural , $ number );
4848 }
@@ -60,9 +60,9 @@ function npgettext($context, $singular, $plural, $number)
6060 * @param string $message The message being translated
6161 * @return string Translated string if one is found in the translation table, or the submitted message if not found
6262 */
63- function dpgettext ($ domain , $ context , $ message )
63+ function dpgettext (string $ domain , string $ context , string $ message ): string
6464 {
65- $ context_message = "{ $ context} \004{ $ message} " ;
65+ $ context_message = "$ context \004$ message " ;
6666
6767 $ translation = dgettext ($ domain , $ context_message );
6868
@@ -87,15 +87,15 @@ function dpgettext($domain, $context, $message)
8787 * @param int $number The number (e.g. item count) to determine the translation for the respective grammatical number
8888 * @return string Translated string if one is found in the translation table, or the submitted message if not found
8989 */
90- function dnpgettext ($ domain , $ context , $ singular , $ plural , $ number )
90+ function dnpgettext (string $ domain , string $ context , string $ singular , string $ plural , int $ number ): string
9191 {
92- $ context_singular = "{ $ context} \004{ $ singular} " ;
93- $ context_plural = "{ $ context} \004{ $ plural} " ;
92+ $ context_singular = "$ context \004$ singular " ;
93+ $ context_plural = "$ context \004$ plural " ;
9494
9595 $ translation = dngettext ($ domain , $ context_singular , $ context_plural , $ number );
9696
9797 // If the translation was not found...
98- if ($ translation === $ context_singular or $ translation === $ context_plural ) {
98+ if ($ translation === $ context_singular || $ translation === $ context_plural ) {
9999 // Use native function to return the appropriate string
100100 return dngettext ($ domain , $ singular , $ plural , $ number );
101101 }
0 commit comments