Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes issue #1549 corrected CFormatter::sizeFormat

translations for sizeFormat changed to choice format.
improved number formatting
fixed translations
  • Loading branch information...
commit 027c1422de172373061ea845456a758776ae20f6 1 parent 035ab61
@cebe cebe authored
View
30 framework/messages/cs/size_units.php
@@ -1,30 +0,0 @@
-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- */
-return array (
- '{n} B' => '{n} B',
- '{n} Bytes' => '{n} bajtů',
- '{n} GB' => '{n} GB',
- '{n} GigaBytes' => '{n} gigabajtů',
- '{n} KB' => '{n} KB',
- '{n} KiloBytes' => '{n} kilobajtů',
- '{n} MB' => '{n} MB',
- '{n} MegaBytes' => '{n} megabajtů',
- '{n} TB' => '{n} TB',
- '{n} TeraBytes' => '{n} terabajtů',
-);
View
10 framework/messages/cs/yii.php
@@ -235,5 +235,15 @@
'{controller} cannot find the requested view "{view}".' => '{controller} nenalezl požadovanou šablonu "{view}".',
'{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => '{controller} obsahuje nesprávně umístěné Widget tagy v šabloně "{view}". Blok pro {widget} nemá korektně ukončený blok volaní metody endWidget().',
'{controller} has an extra endWidget({id}) call in its view.' => '{controller} má navíc volanou metodu endWidget({id}) v šabloně.',
+ '{n} B' => '{n} B',
+ '{n} byte|{n} bytes' => '{n} bajtů',
+ '{n} GB' => '{n} GB',
+ '{n} gigabyte|{n} gigabytes' => '{n} gigabajtů',
+ '{n} KB' => '{n} KB',
+ '{n} kilobyte|{n} kilobytes' => '{n} kilobajtů',
+ '{n} MB' => '{n} MB',
+ '{n} megabyte|{n} megabytes' => '{n} megabajtů',
+ '{n} TB' => '{n} TB',
+ '{n} terabyte|{n} terabytes' => '{n} terabajtů',
'{widget} cannot find the view "{view}".' => '{widget} nenalezl šablonu "{view}".',
);
View
30 framework/messages/de/size_units.php
@@ -1,30 +0,0 @@
-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- */
-return array (
- '{n} B' => '{n} B',
- '{n} Bytes' => '{n} Byte',
- '{n} GB' => '{n} GB',
- '{n} GigaBytes' => '{n} Gigabyte',
- '{n} KB' => '{n} KB',
- '{n} KiloBytes' => '{n} Kilobyte',
- '{n} MB' => '{n} MB',
- '{n} MegaBytes' => '{n} Megabyte',
- '{n} TB' => '{n} TB',
- '{n} TeraBytes' => '{n} Terabyte',
-);
View
10 framework/messages/de/yii.php
@@ -250,5 +250,15 @@
'{controller} cannot find the requested view "{view}".' => '{controller} kann den angeforderten View "{view}" nicht finden.',
'{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => '{controller} enthält falsch verschachtelte Widget-Tags im View "{view}". Ein {widget}-Widget hat keinen endwidget()-Aufruf.',
'{controller} has an extra endWidget({id}) call in its view.' => '{controller} hat einen überzähligen endwidget({id})-Aufruf in seinem View.',
+ '{n} B' => '{n} B',
+ '{n} byte|{n} bytes' => '{n} Byte',
+ '{n} GB' => '{n} GB',
+ '{n} gigabyte|{n} gigabytes' => '{n} Gigabyte',
+ '{n} KB' => '{n} KB',
+ '{n} kilobyte|{n} kilobytes' => '{n} Kilobyte',
+ '{n} MB' => '{n} MB',
+ '{n} megabyte|{n} megabytes' => '{n} Megabyte',
+ '{n} TB' => '{n} TB',
+ '{n} terabyte|{n} terabytes' => '{n} Terabyte',
'{widget} cannot find the view "{view}".' => '{widget} kann den View "{view}" nicht finden.',
);
View
30 framework/messages/el/size_units.php
@@ -1,30 +0,0 @@
-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- */
-return array (
- '{n} B' => '{n} B',
- '{n} Bytes' => '{n} Bytes',
- '{n} GB' => '{n} GB',
- '{n} GigaBytes' => '{n} GigaBytes',
- '{n} KB' => '{n} KB',
- '{n} KiloBytes' => '{n} KiloBytes',
- '{n} MB' => '{n} MB',
- '{n} MegaBytes' => '{n} MegaBytes',
- '{n} TB' => '{n} TB',
- '{n} TeraBytes' => '{n} TeraBytes',
-);
View
10 framework/messages/el/yii.php
@@ -251,5 +251,15 @@
'{controller} cannot find the requested view "{view}".' => 'Ο ελεγκτής {controller} δεν μπορεί να βρει την καλούμενη όψη "{view}".',
'{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => 'Ο ελεγκτής {controller} περιέχει λάθος εμφωλευμένες σημάνσεις widget στην όψη "{view}". Το widget {widget} δεν περιέχει την κλήση endWidget().',
'{controller} has an extra endWidget({id}) call in its view.' => 'Ο ελεγκτής {controller} έχει μια επιπλέον κλήση endWidget({id}) στην όψη του.',
+ '{n} B' => '',
+ '{n} byte|{n} bytes' => '',
+ '{n} GB' => '',
+ '{n} gigabyte|{n} gigabytes' => '',
+ '{n} KB' => '',
+ '{n} kilobyte|{n} kilobytes' => '',
+ '{n} MB' => '',
+ '{n} megabyte|{n} megabytes' => '',
+ '{n} TB' => '',
+ '{n} terabyte|{n} terabytes' => '',
'{widget} cannot find the view "{view}".' => 'Το widget {widget} δεν μπορεί να βρει την όψη "{view}".',
);
View
30 framework/messages/ja/size_units.php
@@ -1,30 +0,0 @@
-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- */
-return array (
- '{n} B' => '',
- '{n} Bytes' => '{n} バイト',
- '{n} GB' => '',
- '{n} GigaBytes' => '{n} ギガバイト',
- '{n} KB' => '',
- '{n} KiloBytes' => '{n} キロバイト',
- '{n} MB' => '',
- '{n} MegaBytes' => '{n} メガバイト',
- '{n} TB' => '',
- '{n} TeraBytes' => '{n} テラバイト',
-);
View
10 framework/messages/ja/yii.php
@@ -253,5 +253,15 @@
'{controller} cannot find the requested view "{view}".' => '{controller} はリクエストされたビュー "{view}" を見つけられません。',
'{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => '{controller} にはビュー"{view}"の中に不適切にネストされたウィジェットタグがあります。{widget} ウィジェットには endWidget() 呼び出しがありません。',
'{controller} has an extra endWidget({id}) call in its view.' => '{controller} のビューには余分な endWidget({id}) 呼び出しがあります。',
+ '{n} B' => '',
+ '{n} byte|{n} bytes' => '{n} バイト',
+ '{n} GB' => '',
+ '{n} gigabyte|{n} gigabytes' => '{n} ギガバイト',
+ '{n} KB' => '',
+ '{n} kilobyte|{n} kilobytes' => '{n} キロバイト',
+ '{n} MB' => '',
+ '{n} megabyte|{n} megabytes' => '{n} メガバイト',
+ '{n} TB' => '',
+ '{n} terabyte|{n} terabytes' => '{n} テラバイト',
'{widget} cannot find the view "{view}".' => '{widget} はビュー "{view}" を見つけられません。',
);
View
32 framework/messages/kk/size_units.php
@@ -1,32 +0,0 @@
-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- */
-
-// contrary to the russian language, in kazakh numerals are not declined
-return array(
- '{n} B' => '{n} Б',
- '{n} Bytes' => '{n} байт',
- '{n} GB' => '{n} ГБ',
- '{n} GigaBytes' => '{n} гигабайт',
- '{n} KB' => '{n} КБ',
- '{n} KiloBytes' => '{n} килобайт',
- '{n} MB' => '{n} МБ',
- '{n} MegaBytes' => '{n} мегабайт',
- '{n} TB' => '{n} ТБ',
- '{n} TeraBytes' => '{n} терабайт',
-);
View
11 framework/messages/kk/yii.php
@@ -255,5 +255,16 @@
'{controller} cannot find the requested view "{view}".' => '{controller} контролері "{view}" көрінісін таба алмады.',
'{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => '{controller} контролерінің "{view}" көрінісінде қате ішке салынған виджеттер тегтері бар. {widget} виджетінде endWidget() шақыруы қолданылмайды.',
'{controller} has an extra endWidget({id}) call in its view.' => '{controller} контролерінің көрінісінде endWidget({id}) артық шақыруы бар.',
+ // contrary to the russian language, in kazakh numerals are not declined
+ '{n} B' => '{n} Б',
+ '{n} byte|{n} bytes' => '{n} байт',
+ '{n} GB' => '{n} ГБ',
+ '{n} gigabyte|{n} gigabytes' => '{n} гигабайт',
+ '{n} KB' => '{n} КБ',
+ '{n} kilobyte|{n} kilobytes' => '{n} килобайт',
+ '{n} MB' => '{n} МБ',
+ '{n} megabyte|{n} megabytes' => '{n} мегабайт',
+ '{n} TB' => '{n} ТБ',
+ '{n} terabyte|{n} terabytes' => '{n} терабайт',
'{widget} cannot find the view "{view}".' => '{widget} виджеті "{view}" көрінісін таба алмады.',
);
View
30 framework/messages/nl/size_units.php
@@ -1,30 +0,0 @@
-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- */
-return array (
- '{n} B' => '',
- '{n} Bytes' => '',
- '{n} GB' => '',
- '{n} GigaBytes' => '',
- '{n} KB' => '',
- '{n} KiloBytes' => '',
- '{n} MB' => '',
- '{n} MegaBytes' => '',
- '{n} TB' => '',
- '{n} TeraBytes' => '',
-);
View
10 framework/messages/nl/yii.php
@@ -253,5 +253,15 @@
'{controller} cannot find the requested view "{view}".' => '{controller} kan de opgevraagde view "{view}" niet vinden.',
'{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => '{controller} bevat ongeldig genestelde widget tags in z\'n view "{view}". De {widget} widget roept endWidget() niet aan.',
'{controller} has an extra endWidget({id}) call in its view.' => '{controller} heeft een extra endWidget({id})-aanroep in z\'n view',
+ '{n} B' => '',
+ '{n} byte|{n} bytes' => '',
+ '{n} GB' => '',
+ '{n} gigabyte|{n} gigabytes' => '',
+ '{n} KB' => '',
+ '{n} kilobyte|{n} kilobytes' => '',
+ '{n} MB' => '',
+ '{n} megabyte|{n} megabytes' => '',
+ '{n} TB' => '',
+ '{n} terabyte|{n} terabytes' => '',
'{widget} cannot find the view "{view}".' => '{widget} kan het viewbestand "{view}" niet vinden.',
);
View
30 framework/messages/ru/size_units.php
@@ -1,30 +0,0 @@
-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- */
-return array (
- '{n} B' => '{n} Б',
- '{n} Bytes' => '{n} байт|{n} байта|{n} байтов|{n} байта',
- '{n} GB' => '{n} ГБ',
- '{n} GigaBytes' => '{n} гигабайт|{n} гигабайта|{n} гигабайтов|{n} гигабайта',
- '{n} KB' => '{n} КБ',
- '{n} KiloBytes' => '{n} килобайт|{n} килобайта|{n} килобайтов|{n} килобайта',
- '{n} MB' => '{n} МБ',
- '{n} MegaBytes' => '{n} мегабайт|{n} мегабайта|{n} мегабайтов|{n} мегабайта',
- '{n} TB' => '{n} ТБ',
- '{n} TeraBytes' => '{n} терабайт|{n} терабайта|{n} терабайтов|{n} терабайта',
-);
View
10 framework/messages/ru/yii.php
@@ -255,5 +255,15 @@
'{controller} cannot find the requested view "{view}".' => 'Контроллер {controller} не может найти представление "{view}".',
'{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => 'Контроллер {controller} содержит в своем представлении "{view}" тэги виджетов с неправильной вложенностью. В виджете {widget} не используется вызов endWidget().',
'{controller} has an extra endWidget({id}) call in its view.' => 'В представлении контроллера {controller} обнаружен лишний вызов endWidget({id}).',
+ '{n} B' => '{n} Б',
+ '{n} byte|{n} bytes' => '{n} байт|{n} байта|{n} байтов|{n} байта',
+ '{n} GB' => '{n} ГБ',
+ '{n} gigabyte|{n} gigabytes' => '{n} гигабайт|{n} гигабайта|{n} гигабайтов|{n} гигабайта',
+ '{n} KB' => '{n} КБ',
+ '{n} kilobyte|{n} kilobytes' => '{n} килобайт|{n} килобайта|{n} килобайтов|{n} килобайта',
+ '{n} MB' => '{n} МБ',
+ '{n} megabyte|{n} megabytes' => '{n} мегабайт|{n} мегабайта|{n} мегабайтов|{n} мегабайта',
+ '{n} TB' => '{n} ТБ',
+ '{n} terabyte|{n} terabytes' => '{n} терабайт|{n} терабайта|{n} терабайтов|{n} терабайта',
'{widget} cannot find the view "{view}".' => 'Виджет {widget} не может найти представление "{view}".',
);
View
30 framework/messages/sk/size_units.php
@@ -1,30 +0,0 @@
-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- */
-return array (
- '{n} B' => '{n} B',
- '{n} Bytes' => '{n} bajtov',
- '{n} GB' => '{n} GB',
- '{n} GigaBytes' => '{n} gigabajtov',
- '{n} KB' => '{n} KB',
- '{n} KiloBytes' => '{n} kilobajtov',
- '{n} MB' => '{n} MB',
- '{n} MegaBytes' => '{n} megabajtov',
- '{n} TB' => '{n} TB',
- '{n} TeraBytes' => '{n} terabajtov',
-);
View
10 framework/messages/sk/yii.php
@@ -253,5 +253,15 @@
'{controller} cannot find the requested view "{view}".' => '{controller} nenašiel požadovanú šablónu "{view}".',
'{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => '{controller} obsahuje nesprávne umiestnené Widget tagy v šablóne "{view}". Blok pre {widget} nemá korektne ukončený blok zavolaním metódy endWidget().',
'{controller} has an extra endWidget({id}) call in its view.' => '{controller} má naviac volanú metódu endWidget ({id}) v šablóne.',
+ '{n} B' => '{n} B',
+ '{n} byte|{n} bytes' => '{n} bajtov',
+ '{n} GB' => '{n} GB',
+ '{n} gigabyte|{n} gigabytes' => '{n} gigabajtov',
+ '{n} KB' => '{n} KB',
+ '{n} kilobyte|{n} kilobytes' => '{n} kilobajtov',
+ '{n} MB' => '{n} MB',
+ '{n} megabyte|{n} megabytes' => '{n} megabajtov',
+ '{n} TB' => '{n} TB',
+ '{n} terabyte|{n} terabytes' => '{n} terabajtov',
'{widget} cannot find the view "{view}".' => '{widget} nenašiel šablónu "{view}".',
);
View
30 framework/messages/uk/size_units.php
@@ -1,30 +0,0 @@
-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- */
-return array (
- '{n} B' => '{n} Б',
- '{n} Bytes' => '{n} байт|{n} байта|{n} байтів|{n} байта',
- '{n} GB' => '{n} ГБ',
- '{n} GigaBytes' => '{n} гігабайт|{n} гігабайта|{n} гігабайтів|{n} гігабайта',
- '{n} KB' => '{n} КБ',
- '{n} KiloBytes' => '{n} кілобайт|{n} кілобайта|{n} кілобайтів|{n} кілобайта',
- '{n} MB' => '{n} МБ',
- '{n} MegaBytes' => '{n} мегабайт|{n} мегабайта|{n} мегабайтів|{n} мегабайта',
- '{n} TB' => '{n} ТБ',
- '{n} TeraBytes' => '{n} терабайт|{n} терабайта|{n} терабайтів|{n} терабайта',
-);
View
10 framework/messages/uk/yii.php
@@ -251,5 +251,15 @@
'{controller} cannot find the requested view "{view}".' => 'Контролер {controller} не може знайти представлення "{view}".',
'{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => 'Контролер {controller} містить у своєму представленні "{view}" теги віджетів із невірною вкладеністю. У віджеті {widget} не використовується виклик endWidget().',
'{controller} has an extra endWidget({id}) call in its view.' => 'У представленні контролера {controller} виявлено зайвий виклик endWidget({id}).',
+ '{n} B' => '{n} Б',
+ '{n} byte|{n} bytes' => '{n} байт|{n} байта|{n} байтів|{n} байта',
+ '{n} GB' => '{n} ГБ',
+ '{n} gigabyte|{n} gigabytes' => '{n} гігабайт|{n} гігабайта|{n} гігабайтів|{n} гігабайта',
+ '{n} KB' => '{n} КБ',
+ '{n} kilobyte|{n} kilobytes' => '{n} кілобайт|{n} кілобайта|{n} кілобайтів|{n} кілобайта',
+ '{n} MB' => '{n} МБ',
+ '{n} megabyte|{n} megabytes' => '{n} мегабайт|{n} мегабайта|{n} мегабайтів|{n} мегабайта',
+ '{n} TB' => '{n} ТБ',
+ '{n} terabyte|{n} terabytes' => '{n} терабайт|{n} терабайта|{n} терабайтів|{n} терабайта',
'{widget} cannot find the view "{view}".' => 'Віджет {widget} не може знайти представлення "{view}".',
);
View
29 framework/utils/CFormatter.php
@@ -66,8 +66,8 @@ class CFormatter extends CApplicationComponent
public $datetimeFormat='Y/m/d h:i:s A';
/**
* @var array the format used to format a number with PHP number_format() function.
- * Three elements may be specified: "decimals", "decimalSeparator" and "thousandSeparator". They
- * correspond to the number of digits after the decimal point, the character displayed as the decimal point,
+ * Three elements may be specified: "decimals", "decimalSeparator" and "thousandSeparator".
+ * They correspond to the number of digits after the decimal point, the character displayed as the decimal point
* and the thousands separator character.
*/
public $numberFormat=array('decimals'=>null, 'decimalSeparator'=>null, 'thousandSeparator'=>null);
@@ -82,15 +82,17 @@ class CFormatter extends CApplicationComponent
* @since 1.1.13
*/
public $htmlPurifierOptions=array();
-
/**
- * @var array the format used to format size (bytes). Two elements may be specified: "base" and "decimals".
- * They correspond to the base at which KiloByte is calculated (1000 or 1024) bytes per KiloByte and
- * the number of digits after decimal point.
+ * @var array the format used to format size (bytes). Three elements may be specified: "base", "decimals" and "decimalSeparator".
+ * They correspond to the base at which a kilobyte is calculated (1000 or 1024 bytes per kilobyte, defaults to 1024),
+ * the number of digits after the decimal point (defaults to 2) and the character displayed as the decimal point.
+ * "decimalSeparator" is available since version 1.1.13
+ * @since 1.1.11
*/
public $sizeFormat=array(
'base'=>1024,
'decimals'=>2,
+ 'decimalSeparator'=>null,
);
/**
@@ -279,9 +281,10 @@ public function getHtmlPurifier()
/**
* Formats the value in bytes as a size in human readable form.
* @param integer $value value in bytes to be formatted
- * @param boolean $verbose if full names should be used (e.g. Bytes, KiloBytes, ...).
+ * @param boolean $verbose if full names should be used (e.g. bytes, kilobytes, ...).
* Defaults to false meaning that short names will be used (e.g. B, KB, ...).
* @return string the formatted result
+ * @see sizeFormat
* @since 1.1.11
*/
public function formatSize($value,$verbose=false)
@@ -291,19 +294,21 @@ public function formatSize($value,$verbose=false)
$value=$value/$base;
$value=round($value, $this->sizeFormat['decimals']);
+ $formattedValue=isset($this->sizeFormat['decimalSeparator']) ? str_replace('.',$this->sizeFormat['decimalSeparator'],$value) : $value;
+ $params=array($value,'{n}'=>$formattedValue);
switch($i)
{
case 0:
- return $verbose ? Yii::t('size_units', '{n} Bytes', $value) : Yii::t('size_units', '{n} B', $value);
+ return $verbose ? Yii::t('yii','{n} byte|{n} bytes',$params) : Yii::t('yii', '{n} B',$params);
case 1:
- return $verbose ? Yii::t('size_units', '{n} KiloBytes', $value) : Yii::t('size_units', '{n} KB', $value);
+ return $verbose ? Yii::t('yii','{n} kilobyte|{n} kilobytes',$params) : Yii::t('yii','{n} KB',$params);
case 2:
- return $verbose ? Yii::t('size_units', '{n} MegaBytes', $value) : Yii::t('size_units', '{n} MB', $value);
+ return $verbose ? Yii::t('yii','{n} megabyte|{n} megabytes',$params) : Yii::t('yii','{n} MB',$params);
case 3:
- return $verbose ? Yii::t('size_units', '{n} GigaBytes', $value) : Yii::t('size_units', '{n} GB', $value);
+ return $verbose ? Yii::t('yii','{n} gigabyte|{n} gigabytes',$params) : Yii::t('yii','{n} GB',$params);
default:
- return $verbose ? Yii::t('size_units', '{n} TeraBytes', $value) : Yii::t('size_units', '{n} TB', $value);
+ return $verbose ? Yii::t('yii','{n} terabyte|{n} terabytes',$params) : Yii::t('yii','{n} TB',$params);
}
}
}
View
76 tests/framework/utils/CFormatterTest.php
@@ -0,0 +1,76 @@
+<?php
+
+class CFormatterTest extends CTestCase
+{
+ /**
+ * Test formatting size numbers in bytes, kilobytes, ...
+ */
+ public function testSizeFormat()
+ {
+ $formatter = new CFormatter();
+
+ Yii::app()->language = 'en';
+ $this->assertEquals('1 byte', $formatter->formatSize(1, true));
+ $this->assertEquals('10 bytes', $formatter->formatSize(10, true));
+ $this->assertEquals('1 kilobyte', $formatter->formatSize(1024, true));
+ $this->assertEquals('1.5 kilobytes', $formatter->formatSize(1536, true));
+ $this->assertEquals('1.51 kilobytes', $formatter->formatSize(1550, true));
+ $formatter->sizeFormat['decimals']=3;
+ $this->assertEquals('1.514 kilobytes', $formatter->formatSize(1550, true));
+ $formatter->sizeFormat['decimals']=4;
+ $this->assertEquals('1.5137 kilobytes', $formatter->formatSize(1550, true));
+
+ $this->assertEquals('1 B', $formatter->formatSize(1, false));
+ $this->assertEquals('10 B', $formatter->formatSize(10, false));
+ $this->assertEquals('1 KB', $formatter->formatSize(1024, false));
+ $this->assertEquals('1.5 KB', $formatter->formatSize(1536, false));
+
+ $this->assertEquals('1 byte', $formatter->formatSize(1, true));
+ $this->assertEquals('1 kilobyte', $formatter->formatSize(1024, true));
+ $this->assertEquals('1 megabyte', $formatter->formatSize(1024 * 1024, true));
+ $this->assertEquals('1 gigabyte', $formatter->formatSize(1024 * 1024 * 1024, true));
+ $this->assertEquals('1 terabyte', $formatter->formatSize(1024 * 1024 * 1024 * 1024, true));
+
+ Yii::app()->language = 'de';
+ $formatter->sizeFormat['decimalSeparator']=',';
+ $this->assertEquals('1 Byte', $formatter->formatSize(1, true));
+ $this->assertEquals('10 Byte', $formatter->formatSize(10, true));
+ $this->assertEquals('1 Kilobyte', $formatter->formatSize(1024, true));
+ $this->assertEquals('1,5 Kilobyte', $formatter->formatSize(1536, true));
+ }
+
+ public function languages()
+ {
+ return array(
+ array('cs'),
+ array('de'),
+ array('ja'),
+ array('kk'),
+ array('ru'),
+ array('sk'),
+ array('uk'),
+ );
+ }
+
+ /**
+ * This test is to check whether messages get actually translated to non-english
+ *
+ * @dataProvider languages
+ * @param $language
+ */
+ public function testSizeFormatTranslation($language)
+ {
+ $formatter = new CFormatter();
+
+ Yii::app()->language = $language;
+ $this->assertNotEquals('1 byte', $formatter->formatSize(1, true));
+ $this->assertNotEquals('1 kilobyte', $formatter->formatSize(1024, true));
+ $this->assertNotEquals('1 megabyte', $formatter->formatSize(1024 * 1024, true));
+ $this->assertNotEquals('1 gigabyte', $formatter->formatSize(1024 * 1024 * 1024, true));
+ $this->assertNotEquals('1 terabyte', $formatter->formatSize(1024 * 1024 * 1024 * 1024, true));
+
+ // test sizeformat works with non integers
+ $formatter->sizeFormat['decimals']=4;
+ $this->assertNotEquals('1.5137 kilobytes', $formatter->formatSize(1550, true));
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.