PHP switch and translations Given a PHP switch statement, would it be a good (or bad) idea to use t() in case statements?

switch ($button_value) {
  case t('Clear'):
    // …
    break;
  case t('Search'):
    // …
    break;
}
In general, it would be a bad development practice. The whole purpose of t() is to provide human-readable translated text. As such, it can't be guaranteed as consistent switch logic because the translation context might differ.

In practice (e.g. a input button submit value on a basic form with little-to-no translation contexts), you might get away with it, but you're adding technical debt; if your application grows and other features start to rely on the switch logic, it's only a matter of time before the inconsistent logic will bite you.