Skip to content

Instantly share code, notes, and snippets.

@bashaus
Created January 3, 2018 15:52
Show Gist options
  • Select an option

  • Save bashaus/5d21bf266da08f222c808fbacf2f47dd to your computer and use it in GitHub Desktop.

Select an option

Save bashaus/5d21bf266da08f222c808fbacf2f47dd to your computer and use it in GitHub Desktop.
Generates a .POT file to provide a template for translating a WordPress plugin or template
# Dependencies
# - *NIX or Mac operating system
# - gettext installed
#
# Instructions
# - Run this script in the root directory of your theme or plugin
#
# About WordPress L10N functions:
# @see https://codex.wordpress.org/L10n
#
# Manual for xgettext
# @see https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html
find . -name "*.php" | \
xargs xgettext \
--from-code=UTF-8 \
--keyword="__:1" \
--keyword="_e:1" \
--keyword="_n:1,2" \
--keyword="_x:1,2c" \
--keyword="_ex:1,2c" \
--keyword="_nx:1,2,4c" \
--keyword="esc_html__:1" \
--keyword="esc_html_e:1" \
--keyword="esc_html_x:1,2c" \
--keyword="esc_attr__:1" \
--keyword="esc_attr_e:1" \
--keyword="esc_attr_x:1,2c" \
--language=PHP \
--output=languages/default.pot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment