Index: branches/wmf/1.17wmf1/languages/messages/MessagesEn.php |
— | — | @@ -3592,9 +3592,15 @@ |
3593 | 3593 | |
3594 | 3594 | # Video information, used by Language::formatTimePeriod() to format lengths in the above messages |
3595 | 3595 | 'video-dims' => '$1, $2×$3', # only translate this message to other languages if you have to change it |
3596 | | -'seconds-abbrev' => 's', # only translate this message to other languages if you have to change it |
3597 | | -'minutes-abbrev' => 'm', # only translate this message to other languages if you have to change it |
3598 | | -'hours-abbrev' => 'h', # only translate this message to other languages if you have to change it |
| 3596 | +'seconds-abbrev' => '$1s', # only translate this message to other languages if you have to change it |
| 3597 | +'minutes-abbrev' => '$1m', # only translate this message to other languages if you have to change it |
| 3598 | +'hours-abbrev' => '$1h', # only translate this message to other languages if you have to change it |
| 3599 | +'days-abbrev' => '$1d', # only translate this message to other languages if you have to change it |
| 3600 | +'seconds' => '{{PLURAL:$1|$1 second|$1 seconds}}', |
| 3601 | +'minutes' => '{{PLURAL:$1|$1 minute|$1 minutes}}', |
| 3602 | +'hours' => '{{PLURAL:$1|$1 hour|$1 hours}}', |
| 3603 | +'days' => '{{PLURAL:$1|$1 day|$1 days}}', |
| 3604 | +'ago' => '$1 ago', |
3599 | 3605 | |
3600 | 3606 | # Bad image list |
3601 | 3607 | 'bad_image_list' => 'The format is as follows: |
Property changes on: branches/wmf/1.17wmf1/languages/messages/MessagesEn.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
3602 | 3608 | Merged /trunk/phase3/languages/messages/MessagesEn.php:r95318,97962,98006 |
Index: branches/wmf/1.17wmf1/languages/Language.php |
— | — | @@ -2904,11 +2904,37 @@ |
2905 | 2905 | return array( $wikiUpperChars, $wikiLowerChars ); |
2906 | 2906 | } |
2907 | 2907 | |
2908 | | - function formatTimePeriod( $seconds ) { |
| 2908 | + /** |
| 2909 | + * @todo Document |
| 2910 | + * @param $seconds int|float |
| 2911 | + * @param $format Array Optional |
| 2912 | + * If $format['avoid'] == 'avoidseconds' - don't mention seconds if $seconds >= 1 hour |
| 2913 | + * If $format['avoid'] == 'avoidminutes' - don't mention seconds/minutes if $seconds > 48 hours |
| 2914 | + * If $format['noabbrevs'] is true - use 'seconds' and friends instead of 'seconds-abbrev' and friends |
| 2915 | + * For backwards compatibility, $format may also be one of the strings 'avoidseconds' or 'avoidminutes' |
| 2916 | + * @return string |
| 2917 | + */ |
| 2918 | + function formatTimePeriod( $seconds, $format = array() ) { |
| 2919 | + if ( !is_array( $format ) ) { |
| 2920 | + $format = array( 'avoid' => $format, 'noabbrevs' => false ); // For backwards compatibility |
| 2921 | + } |
| 2922 | + if ( !isset( $format['avoid'] ) ) { |
| 2923 | + $format['avoid'] = false; |
| 2924 | + } |
| 2925 | + if ( !isset( $format['noabbrevs' ] ) ) { |
| 2926 | + $format['noabbrevs'] = false; |
| 2927 | + } |
| 2928 | + $secondsMsg = wfMessage( $format['noabbrevs'] ? 'seconds' : 'seconds-abbrev' )->inLanguage( $this ); |
| 2929 | + $minutesMsg = wfMessage( $format['noabbrevs'] ? 'minutes' : 'minutes-abbrev' )->inLanguage( $this ); |
| 2930 | + $hoursMsg = wfMessage( $format['noabbrevs'] ? 'hours' : 'hours-abbrev' )->inLanguage( $this ); |
| 2931 | + $daysMsg = wfMessage( $format['noabbrevs'] ? 'days' : 'days-abbrev' )->inLanguage( $this ); |
| 2932 | + |
2909 | 2933 | if ( round( $seconds * 10 ) < 100 ) { |
2910 | | - return $this->formatNum( sprintf( "%.1f", round( $seconds * 10 ) / 10 ) ) . $this->getMessageFromDB( 'seconds-abbrev' ); |
| 2934 | + $s = $this->formatNum( sprintf( "%.1f", round( $seconds * 10 ) / 10 ) ); |
| 2935 | + $s = $secondsMsg->params( $s )->text(); |
2911 | 2936 | } elseif ( round( $seconds ) < 60 ) { |
2912 | | - return $this->formatNum( round( $seconds ) ) . $this->getMessageFromDB( 'seconds-abbrev' ); |
| 2937 | + $s = $this->formatNum( round( $seconds ) ); |
| 2938 | + $s = $secondsMsg->params( $s )->text(); |
2913 | 2939 | } elseif ( round( $seconds ) < 3600 ) { |
2914 | 2940 | $minutes = floor( $seconds / 60 ); |
2915 | 2941 | $secondsPart = round( fmod( $seconds, 60 ) ); |
— | — | @@ -2916,9 +2942,10 @@ |
2917 | 2943 | $secondsPart = 0; |
2918 | 2944 | $minutes++; |
2919 | 2945 | } |
2920 | | - return $this->formatNum( $minutes ) . $this->getMessageFromDB( 'minutes-abbrev' ) . ' ' . |
2921 | | - $this->formatNum( $secondsPart ) . $this->getMessageFromDB( 'seconds-abbrev' ); |
2922 | | - } else { |
| 2946 | + $s = $minutesMsg->params( $this->formatNum( $minutes ) )->text(); |
| 2947 | + $s .= ' '; |
| 2948 | + $s .= $secondsMsg->params( $this->formatNum( $secondsPart ) )->text(); |
| 2949 | + } elseif ( round( $seconds ) <= 2 * 86400 ) { |
2923 | 2950 | $hours = floor( $seconds / 3600 ); |
2924 | 2951 | $minutes = floor( ( $seconds - $hours * 3600 ) / 60 ); |
2925 | 2952 | $secondsPart = round( $seconds - $hours * 3600 - $minutes * 60 ); |
— | — | @@ -2930,10 +2957,46 @@ |
2931 | 2958 | $minutes = 0; |
2932 | 2959 | $hours++; |
2933 | 2960 | } |
2934 | | - return $this->formatNum( $hours ) . $this->getMessageFromDB( 'hours-abbrev' ) . ' ' . |
2935 | | - $this->formatNum( $minutes ) . $this->getMessageFromDB( 'minutes-abbrev' ) . ' ' . |
2936 | | - $this->formatNum( $secondsPart ) . $this->getMessageFromDB( 'seconds-abbrev' ); |
| 2961 | + $s = $hoursMsg->params( $this->formatNum( $hours ) )->text(); |
| 2962 | + $s .= ' '; |
| 2963 | + $s .= $minutesMsg->params( $this->formatNum( $minutes ) )->text(); |
| 2964 | + if ( !in_array( $format['avoid'], array( 'avoidseconds', 'avoidminutes' ) ) ) { |
| 2965 | + $s .= ' ' . $secondsMsg->params( $this->formatNum( $secondsPart ) )->text(); |
| 2966 | + } |
| 2967 | + } else { |
| 2968 | + $days = floor( $seconds / 86400 ); |
| 2969 | + if ( $format['avoid'] === 'avoidminutes' ) { |
| 2970 | + $hours = round( ( $seconds - $days * 86400 ) / 3600 ); |
| 2971 | + if ( $hours == 24 ) { |
| 2972 | + $hours = 0; |
| 2973 | + $days++; |
| 2974 | + } |
| 2975 | + $s = $daysMsg->params( $this->formatNum( $days ) )->text(); |
| 2976 | + $s .= ' '; |
| 2977 | + $s .= $hoursMsg->params( $this->formatNum( $hours ) )->text(); |
| 2978 | + } elseif ( $format['avoid'] === 'avoidseconds' ) { |
| 2979 | + $hours = floor( ( $seconds - $days * 86400 ) / 3600 ); |
| 2980 | + $minutes = round( ( $seconds - $days * 86400 - $hours * 3600 ) / 60 ); |
| 2981 | + if ( $minutes == 60 ) { |
| 2982 | + $minutes = 0; |
| 2983 | + $hours++; |
| 2984 | + } |
| 2985 | + if ( $hours == 24 ) { |
| 2986 | + $hours = 0; |
| 2987 | + $days++; |
| 2988 | + } |
| 2989 | + $s = $daysMsg->params( $this->formatNum( $days ) )->text(); |
| 2990 | + $s .= ' '; |
| 2991 | + $s .= $hoursMsg->params( $this->formatNum( $hours ) )->text(); |
| 2992 | + $s .= ' '; |
| 2993 | + $s .= $minutesMsg->params( $this->formatNum( $minutes ) )->text(); |
| 2994 | + } else { |
| 2995 | + $s = $daysMsg->params( $this->formatNum( $days ) )->text(); |
| 2996 | + $s .= ' '; |
| 2997 | + $s .= $this->formatTimePeriod( $seconds - $days * 86400, $format ); |
| 2998 | + } |
2937 | 2999 | } |
| 3000 | + return $s; |
2938 | 3001 | } |
2939 | 3002 | |
2940 | 3003 | function formatBitrate( $bps ) { |
Property changes on: branches/wmf/1.17wmf1/languages/Language.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
2941 | 3004 | Merged /trunk/phase3/languages/Language.php:r95318,97962,98006 |