Code Duplication    Length = 26-45 lines in 5 locations

lib/Cake/basics.php 5 locations

@@ 570-598 (lines=29) @@
567
568
}
569
570
if (!function_exists('__n')) {
571
572
/**
573
 * Returns correct plural form of message identified by $singular and $plural for count $count.
574
 * Some languages have more than one form for plural messages dependent on the count.
575
 *
576
 * @param string $singular Singular text to translate
577
 * @param string $plural Plural text
578
 * @param integer $count Count
579
 * @param mixed $args Array with arguments or multiple arguments in function
580
 * @return mixed plural form of translated string
581
 * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__n
582
 */
583
	function __n($singular, $plural, $count, $args = null) {
584
		if (!$singular) {
585
			return;
586
		}
587
588
		App::uses('I18n', 'I18n');
589
		$translated = I18n::translate($singular, $plural, null, 6, $count);
590
		if ($args === null) {
591
			return $translated;
592
		} elseif (!is_array($args)) {
593
			$args = array_slice(func_get_args(), 3);
594
		}
595
		return vsprintf($translated, $args);
596
	}
597
598
}
599
600
if (!function_exists('__d')) {
601
@@ 600-625 (lines=26) @@
597
598
}
599
600
if (!function_exists('__d')) {
601
602
/**
603
 * Allows you to override the current domain for a single message lookup.
604
 *
605
 * @param string $domain Domain
606
 * @param string $msg String to translate
607
 * @param mixed $args Array with arguments or multiple arguments in function
608
 * @return translated string
609
 * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d
610
 */
611
	function __d($domain, $msg, $args = null) {
612
		if (!$msg) {
613
			return;
614
		}
615
		App::uses('I18n', 'I18n');
616
		$translated = I18n::translate($msg, null, $domain);
617
		if ($args === null) {
618
			return $translated;
619
		} elseif (!is_array($args)) {
620
			$args = array_slice(func_get_args(), 2);
621
		}
622
		return vsprintf($translated, $args);
623
	}
624
625
}
626
627
if (!function_exists('__dn')) {
628
@@ 627-656 (lines=30) @@
624
625
}
626
627
if (!function_exists('__dn')) {
628
629
/**
630
 * Allows you to override the current domain for a single plural message lookup.
631
 * Returns correct plural form of message identified by $singular and $plural for count $count
632
 * from domain $domain.
633
 *
634
 * @param string $domain Domain
635
 * @param string $singular Singular string to translate
636
 * @param string $plural Plural
637
 * @param integer $count Count
638
 * @param mixed $args Array with arguments or multiple arguments in function
639
 * @return plural form of translated string
640
 * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dn
641
 */
642
	function __dn($domain, $singular, $plural, $count, $args = null) {
643
		if (!$singular) {
644
			return;
645
		}
646
		App::uses('I18n', 'I18n');
647
		$translated = I18n::translate($singular, $plural, $domain, 6, $count);
648
		if ($args === null) {
649
			return $translated;
650
		} elseif (!is_array($args)) {
651
			$args = array_slice(func_get_args(), 4);
652
		}
653
		return vsprintf($translated, $args);
654
	}
655
656
}
657
658
if (!function_exists('__dc')) {
659
@@ 658-698 (lines=41) @@
655
656
}
657
658
if (!function_exists('__dc')) {
659
660
/**
661
 * Allows you to override the current domain for a single message lookup.
662
 * It also allows you to specify a category.
663
 *
664
 * The category argument allows a specific category of the locale settings to be used for fetching a message.
665
 * Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
666
 *
667
 * Note that the category must be specified with a numeric value, instead of the constant name. The values are:
668
 *
669
 * - LC_ALL       0
670
 * - LC_COLLATE   1
671
 * - LC_CTYPE     2
672
 * - LC_MONETARY  3
673
 * - LC_NUMERIC   4
674
 * - LC_TIME      5
675
 * - LC_MESSAGES  6
676
 *
677
 * @param string $domain Domain
678
 * @param string $msg Message to translate
679
 * @param integer $category Category
680
 * @param mixed $args Array with arguments or multiple arguments in function
681
 * @return translated string
682
 * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dc
683
 */
684
	function __dc($domain, $msg, $category, $args = null) {
685
		if (!$msg) {
686
			return;
687
		}
688
		App::uses('I18n', 'I18n');
689
		$translated = I18n::translate($msg, null, $domain, $category);
690
		if ($args === null) {
691
			return $translated;
692
		} elseif (!is_array($args)) {
693
			$args = array_slice(func_get_args(), 3);
694
		}
695
		return vsprintf($translated, $args);
696
	}
697
698
}
699
700
if (!function_exists('__dcn')) {
701
@@ 700-744 (lines=45) @@
697
698
}
699
700
if (!function_exists('__dcn')) {
701
702
/**
703
 * Allows you to override the current domain for a single plural message lookup.
704
 * It also allows you to specify a category.
705
 * Returns correct plural form of message identified by $singular and $plural for count $count
706
 * from domain $domain.
707
 *
708
 * The category argument allows a specific category of the locale settings to be used for fetching a message.
709
 * Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
710
 *
711
 * Note that the category must be specified with a numeric value, instead of the constant name. The values are:
712
 *
713
 * - LC_ALL       0
714
 * - LC_COLLATE   1
715
 * - LC_CTYPE     2
716
 * - LC_MONETARY  3
717
 * - LC_NUMERIC   4
718
 * - LC_TIME      5
719
 * - LC_MESSAGES  6
720
 *
721
 * @param string $domain Domain
722
 * @param string $singular Singular string to translate
723
 * @param string $plural Plural
724
 * @param integer $count Count
725
 * @param integer $category Category
726
 * @param mixed $args Array with arguments or multiple arguments in function
727
 * @return plural form of translated string
728
 * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dcn
729
 */
730
	function __dcn($domain, $singular, $plural, $count, $category, $args = null) {
731
		if (!$singular) {
732
			return;
733
		}
734
		App::uses('I18n', 'I18n');
735
		$translated = I18n::translate($singular, $plural, $domain, $category, $count);
736
		if ($args === null) {
737
			return $translated;
738
		} elseif (!is_array($args)) {
739
			$args = array_slice(func_get_args(), 5);
740
		}
741
		return vsprintf($translated, $args);
742
	}
743
744
}
745
746
if (!function_exists('__c')) {
747