Drupal 6: Why use tokens in t ()?

I am reading Pro Drupal Development, second edition . It states that the following is necessary:

t("Your favorite color is !color", array('!color' => "$color"));

But it also says that! A placeholder means that no transformation will be performed on the line. So why not just:

t("Your favorite color is $color");

Thanks.

+3
source share
2 answers

t() . ( ), , . .

'!', '%', '@' , , '!' , ​​ .

- :

t("Number $count");

, 1,2,3, , t() :

  • t ('Number 1')
  • t ('Number 2')
  • t ('Number 3')

t('Number !count', array('!count' => $count);

, " " !

, , , , . "count count" . :

  • '1 whatever'
  • '2 whatever
  • '3 whatever'

'%' <em> , '@' check_plain(), .

+12

t() - ; t("Your favorite color is $color") , script . , script "Your favorite color is $color" ( , ), , t().

0

Source: https://habr.com/ru/post/1715825/


All Articles