Skip to content
globe

GitHub Action

Test WordPress language files

v4.0.0 Latest version

Test WordPress language files

globe

Test WordPress language files

Check internationalization files for WordPress plugins for being up-to-date

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Test WordPress language files

uses: holyhope/[email protected]

Learn more about this action in holyhope/test-wordpress-languages-github-action

Choose a version

branding<icon:globe color:blue> GitHub Action: Test WordPress language files

ReleaseReleaseCommitOpen IssuesDownloads

Check internationalization files for WordPress plugins for being up-to-date.

This action checks the i18n files for the WordPress plugin or theme by running wp i18n make-pot and wp i18n update-po. This helps to ensure that the internationalization files are up-to-date and that the translations are not missing.

By default the action fails if the POT or PO files are not up-to-date or if there are warnings on compilation. This can be disabled with the fail_on_diff and fail_on_warning inputs.

The action outputs a patch file with the changes to apply to the files, and a file containing all compiler warnings.

Usage

- uses: holyhope/test-wordpress-languages-github-action@main
  with:
    # Description: Plugin or theme slug.
    #
    slug: ""

    # Description: Directory to scan for string extraction.
    #
    # Default: .
    source: ""

    # Description: Path to an existing POT file to use for updating.
    #
    # Default: `{source}/{slug}.pot`
    #
    pot_file: ""

    # Description: PO files to update or a directory containing multiple PO files.
    #
    # Type: multi-line string
    #
    # Default: all PO files in the source directory with the same prefix as the POT
    # file.
    #
    po_path: ""

    # Description: Path to the languages directory
    #
    # Default: languages
    languages_directory: ""

    # Description: Pattern to ignore when checking the POT file changes.
    #
    # Type: multi-line string
    #
    # Default: "POT-Creation-Date:
    ignored_patterns: ""

    # Description: Text domain to look for in the source code, unless the
    # `ignore-domain` option is `true`.
    #
    # Default: the "Text Domain" header of the plugin or theme is used.
    #
    domain: ""

    # Description: Ignore the text domain completely and extract strings with any text
    # domain.
    #
    # Default: false
    ignore_domain: ""

    # Description: Skips JavaScript string extraction. Useful when this is done in
    # another build step, e.g. through Babel.
    #
    # Default: false
    skip_js: ""

    # Description: Skips PHP string extraction.
    #
    # Default: false
    skip_php: ""

    # Description: Skips Blade-PHP string extraction.
    #
    # Default: false
    skip_blade: ""

    # Description: Skips string extraction from block.json files.
    #
    # Default: false
    skip_block_json: ""

    # Description: Skips string extraction from theme.json files.
    #
    # Default: false
    skip_theme_json: ""

    # Description: Skips string audit where it tries to find possible mistakes in
    # translatable strings.
    #
    # Default: true
    skip_audit: ""

    # Description: List of files and paths that should be skipped for string
    # extraction.
    #
    # Simple glob patterns can be used, i.e. `foo-*.php` excludes any PHP file with
    # the `foo-` prefix. Leading and trailing slashes are ignored, i.e.
    # `/my/directory/` is the same as `my/directory`. The following files and folders
    # are always excluded: node_modules, .git, .svn, .CVS, .hg, vendor, \*.min.js.
    #
    # Type: multi-line string Default: None
    #
    exclude: ""

    # Description: List of files and paths that should be used for string extraction.
    # If provided, only these files and folders will be taken into account for string
    # extraction. Simple glob patterns can be used, i.e. `foo-*.php` includes any PHP
    # file with the `foo-` prefix. Leading and trailing slashes are ignored, i.e.
    # `/my/directory/` is the same as `my/directory`. Type: multi-line string Default:
    # None
    #
    include: ""

    # Description: Whether to write `#: filename:line` lines. Note that disabling this
    # option makes it harder for technically skilled translators to understand each
    # message’s context.
    #
    # Default: true
    location: ""

    # Description: Array in JSON format of custom headers which will be added to the
    # POT file.
    #
    headers: ""

    # Description: String that should be added as a comment to the top of the
    # resulting POT file.
    #
    file_comment: ""

    # Description: Name to use for package name in the resulting POT file's
    # `Project-Id-Version` header. Overrides plugin or theme name, if applicable.
    #
    package_name: ""

    # Description: Whether to fail the build if there are differences in the POT file.
    #
    # Default: true
    fail_on_diff: ""

    # Description: Whether to fail the build if there are warnings.
    #
    # Default: true
    fail_on_warning: ""

    # Description: Path to the WP-CLI binary. To use a custom version of WP-CLI, see
    # the
    # [`install-wp-cli` GitHub action](https://github.com/marketplace/actions/install-wp-cli)
    # Default: Downloaded from the official WP-CLI website.
    #
    wp_cli_path: ""

Inputs

Input Description Default Required
slug Plugin or theme slug. true
source Directory to scan for string extraction. . false
pot_file Path to an existing POT file to use for updating. false
po_path PO files to update or a directory containing multiple PO files. false
languages_directory Path to the languages directory languages false
ignored_patterns Pattern to ignore when checking the POT file changes. "POT-Creation-Date: false
domain unless the ignore-domain option is true. false
ignore_domain Ignore the text domain completely and
extract strings with any text domain.
false
skip_js Skips JavaScript string extraction.
Useful when this is done in another build step, e.g. through Babel.
false
skip_php Skips PHP string extraction. false
skip_blade Skips Blade-PHP string extraction. false
skip_block_json Skips string extraction from block.json files. false
skip_theme_json Skips string extraction from theme.json files. false
skip_audit Skips string audit where it tries
to find possible mistakes in translatable strings.
true false
exclude List of files and paths that should be skipped for string extraction. false
include List of files and paths that should be used for string extraction.
If provided, only these files and folders will be taken into account for string extraction.
Simple glob patterns can be used, i.e. foo-*.php includes any PHP file with the foo- prefix. Leading and trailing slashes are ignored, i.e. /my/directory/ is the same as my/directory.
Type: multi-line string Default: None
false
location Whether to write #: filename:line lines.
Note that disabling this option makes it harder for technically skilled translators to understand each message’s context.
true false
headers Array in JSON format of custom headers which will be added to the POT file. false
file_comment String that should be added as a comment to the top of the resulting POT file. false
package_name Name to use for package name in the resulting POT file's Project-Id-Version header.
Overrides plugin or theme name, if applicable.
false
fail_on_diff Whether to fail the build if there are differences in the POT file. true false
fail_on_warning Whether to fail the build if there are warnings. true false
wp_cli_path Path to the WP-CLI binary.
To use a custom version of WP-CLI, see the install-wp-cli GitHub action
Default: Downloaded from the official WP-CLI website.
false
Output Description
patch_path Path to the patch file containing the changes to apply.
warnings_path Path to the file containing warnings.