X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=d636b4439739bbe210b8b2cdfe08aeff496dcae3;hb=c510db2665c0f580d636f4c3aab72ac20722262b;hp=cf0c4b60af76a7140a76036be43967a60cad0b82;hpb=1993c832779ff758bd005b6a6e24723dce9822ce;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index cf0c4b60af..d636b44397 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -595,6 +595,26 @@ function wfMessage( $key /*...*/) { return new Message( $key, $params ); } +/** + * This function accepts multiple message keys and returns a message instance + * for the first message which is non-empty. If all messages are empty then an + * instance of the first message key is returned. + * Varargs: message keys + * @return \type{Message} + * @since 1.18 + */ +function wfMessageFallback( /*...*/ ) { + $keys = func_get_args(); + $first = $keys[0]; + foreach ( $keys as $key ) { + if ( wfEmptyMsg( $key ) ) { + continue; + } + return wfMessage( $key ); + } + return wfMessage( $first ); +} + /** * Get a message from anywhere, for the current user language. *