All the translation functions

WordPress has a ridiculous number of translation functions to make your life easier. Remember them.

The basics:

  • __() – Translate a string
  • _e() – Echo the translated string
  • _x() – Tell the poor translater what they’re translating
  • _ex() – Tell the poor translater what they’re translating and echo the translated string

Escape the output:

  • esc_attr__() – Escape the translation for HTML attributes
  • esc_attr_e() – Escape and echo the translation for HTML attributes
  • esc_attr_x() – Escape the translation for HTML attributes and tell the translator what they’re translating
  • esc_html__() – Escape the translation for HTML code
  • esc_html_e() – Escape and echo the translation for HTML code
  • esc_html_x() – Escape the translation for HTML code and tell the translator what they’re translation

Handle plurals

2 Comments

Comments are closed.