Skip to content

Commit

Permalink
Merge pull request #17 from wp-cli/rename
Browse files Browse the repository at this point in the history
Rename to i18n-command
  • Loading branch information
schlessera committed Jan 23, 2018
2 parents 3771364 + 490b759 commit 93c1109
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 62 deletions.
4 changes: 3 additions & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ labels:
color: bfe5bf
- name: wontfix
color: c2e0c6
- name: command:makepot
- name: command:i18n
color: c5def5
- name: command:i18n-make-pot
color: c5def5
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
wp-cli/makepot-command
======================
wp-cli/i18n-command
===================

Create POT files for WordPress projects
Provides internationalization tools for WordPress projects.

[![Build Status](https://travis-ci.org/wp-cli/makepot-command.svg?branch=master)](https://travis-ci.org/wp-cli/makepot-command)
[![Build Status](https://travis-ci.org/wp-cli/i18n-command.svg?branch=master)](https://travis-ci.org/wp-cli/i18n-command)

Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing) | [Support](#support)

## Using

This package implements the following commands:

### wp i18n



~~~
wp i18n
~~~





### wp i18n make-pot

Create a POT file for a WordPress plugin or theme.

~~~
wp makepot <source> [<destination>] [--slug=<slug>] [--domain=<domain>]
wp i18n make-pot <source> [<destination>] [--slug=<slug>] [--domain=<domain>]
~~~

**OPTIONS**
Expand All @@ -30,15 +48,15 @@ wp makepot <source> [<destination>] [--slug=<slug>] [--domain=<domain>]
**EXAMPLES**

# Create a POT file for the WordPress plugin/theme in the current directory
$ wp makepot . languages/my-plugin.pot
$ wp i18n make-pot . languages/my-plugin.pot

## Installing

This package is included with WP-CLI itself, no additional installation necessary.

To install the latest version of this package over what's included in WP-CLI, run:

wp package install git@github.com:wp-cli/makepot-command.git
wp package install git@github.com:wp-cli/i18n-command.git

## Contributing

Expand All @@ -52,13 +70,13 @@ For a more thorough introduction, [check out WP-CLI's guide to contributing](htt

Think you’ve found a bug? We’d love for you to help us get it fixed.

Before you create a new issue, you should [search existing issues](https://github.com/wp-cli/makepot-command/issues?q=label%3Abug%20) to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version.
Before you create a new issue, you should [search existing issues](https://github.com/wp-cli/i18n-command/issues?q=label%3Abug%20) to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version.

Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please [create a new issue](https://github.com/wp-cli/makepot-command/issues/new). Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, [review our bug report documentation](https://make.wordpress.org/cli/handbook/bug-reports/).
Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please [create a new issue](https://github.com/wp-cli/i18n-command/issues/new). Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, [review our bug report documentation](https://make.wordpress.org/cli/handbook/bug-reports/).

### Creating a pull request

Want to contribute a new feature? Please first [open a new issue](https://github.com/wp-cli/makepot-command/issues/new) to discuss whether the feature is a good fit for the project.
Want to contribute a new feature? Please first [open a new issue](https://github.com/wp-cli/i18n-command/issues/new) to discuss whether the feature is a good fit for the project.

Once you've decided to commit the time to seeing your pull request through, [please follow our guidelines for creating a pull request](https://make.wordpress.org/cli/handbook/pull-requests/) to make sure it's a pleasant experience. See "[Setting up](https://make.wordpress.org/cli/handbook/pull-requests/#setting-up)" for details specific to working on this package locally.

Expand Down
33 changes: 22 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
{
"name": "wp-cli/makepot-command",
"description": "Create POT files for WordPress projects",
"name": "wp-cli/i18n-command",
"description": "Provides internationalization tools for WordPress projects.",
"type": "wp-cli-package",
"homepage": "https://github.com/wp-cli/makepot-command",
"homepage": "https://github.com/wp-cli/i18n-command",
"support": {
"issues": "https://github.com/wp-cli/i18n-command/issues"
},
"license": "MIT",
"authors": [],
"authors": [
{
"name": "Pascal Birchler",
"homepage": "https://pascalbirchler.com/"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"files": [ "makepot-command.php" ],
"psr-4": {
"WP_CLI\\Makepot\\": "src/"
}
"WP_CLI\\I18n\\": "src/"
},
"files": [
"i18n-command.php"
]
},
"require": {
"wp-cli/wp-cli": "^1.1.0",
"gettext/gettext": "^4.4"
},
"require-dev": {
"wp-cli/wp-cli": "^1.1.0",
"behat/behat": "~2.5"
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"bundled": true,
"commands": [
"makepot"
],
"bundled": true
"i18n",
"i18n make-pot"
]
}
}
28 changes: 14 additions & 14 deletions features/makepot.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Feature: Generate a POT file of a WordPress plugin
Given a WP install

Scenario: Bail for invalid source directories
When I try `wp makepot foo bar/baz.pot`
When I try `wp i18n make-pot foo bar/baz.pot`
Then STDERR should contain:
"""
Error: Not a valid source directory!
Expand All @@ -17,7 +17,7 @@ Feature: Generate a POT file of a WordPress plugin
Then the wp-content/plugins/hello-world directory should exist
And the wp-content/plugins/hello-world/hello-world.php file should exist

When I run `wp makepot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
When I run `wp i18n make-pot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
Then STDOUT should be:
"""
Plugin file detected.
Expand All @@ -29,7 +29,7 @@ Feature: Generate a POT file of a WordPress plugin
Scenario: Does not include empty file headers.
When I run `wp scaffold plugin hello-world --plugin_description=""`

When I run `wp makepot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
When I run `wp i18n make-pot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
Then the wp-content/plugins/hello-world/languages/hello-world.pot file should exist
And the wp-content/plugins/hello-world/languages/hello-world.pot file should not contain:
"""
Expand All @@ -42,7 +42,7 @@ Feature: Generate a POT file of a WordPress plugin
Then STDOUT should not be empty
And save STDOUT as {YEAR}

When I run `wp makepot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
When I run `wp i18n make-pot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
And the wp-content/plugins/hello-world/languages/hello-world.pot file should contain:
"""
# Copyright (C) {YEAR} Hello World
Expand All @@ -52,7 +52,7 @@ Feature: Generate a POT file of a WordPress plugin
Scenario: Sets Project-Id-Version
When I run `wp scaffold plugin hello-world`

When I run `wp makepot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
When I run `wp i18n make-pot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
And the wp-content/plugins/hello-world/languages/hello-world.pot file should contain:
"""
"Project-Id-Version: Hello World 0.1.0\n"
Expand All @@ -61,7 +61,7 @@ Feature: Generate a POT file of a WordPress plugin
Scenario: Sets Report-Msgid-Bugs-To
When I run `wp scaffold plugin hello-world`

When I run `wp makepot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
When I run `wp i18n make-pot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
And the wp-content/plugins/hello-world/languages/hello-world.pot file should contain:
"""
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/hello-world\n"
Expand All @@ -70,7 +70,7 @@ Feature: Generate a POT file of a WordPress plugin
Scenario: Sets the last translator and the language team
When I run `wp scaffold plugin hello-world`

When I run `wp makepot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
When I run `wp i18n make-pot wp-content/plugins/hello-world wp-content/plugins/hello-world/languages/hello-world.pot`
And the wp-content/plugins/hello-world/languages/hello-world.pot file should contain:
"""
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
Expand Down Expand Up @@ -102,7 +102,7 @@ Feature: Generate a POT file of a WordPress plugin
__( 'bar' );
"""

When I run `wp makepot foo-plugin foo-plugin.pot --domain=bar`
When I run `wp i18n make-pot foo-plugin foo-plugin.pot --domain=bar`
And the foo-plugin.pot file should contain:
"""
msgid "Foo"
Expand All @@ -118,7 +118,7 @@ Feature: Generate a POT file of a WordPress plugin

Scenario: Bails when no plugin files are found
Given an empty foo-plugin directory
When I try `wp makepot foo-plugin foo-plugin.pot`
When I try `wp i18n make-pot foo-plugin foo-plugin.pot`
Then STDERR should contain:
"""
Error: No valid theme stylesheet or plugin file found!
Expand All @@ -130,7 +130,7 @@ Feature: Generate a POT file of a WordPress plugin
And a foo-plugin/foo-plugin.php file:
"""
"""
When I try `wp makepot foo-plugin foo-plugin.pot`
When I try `wp i18n make-pot foo-plugin foo-plugin.pot`
Then STDERR should contain:
"""
Error: No valid theme stylesheet or plugin file found!
Expand Down Expand Up @@ -158,7 +158,7 @@ Feature: Generate a POT file of a WordPress plugin
__( 'Hello World', 'foo-plugin' );
"""

When I run `wp makepot foo-plugin foo-plugin.pot`
When I run `wp i18n make-pot foo-plugin foo-plugin.pot`
And the foo-plugin.pot file should contain:
"""
#: foo-plugin.php:15
Expand All @@ -168,7 +168,7 @@ Feature: Generate a POT file of a WordPress plugin
When I run `wp scaffold plugin hello-world`
Then the wp-content/plugins/hello-world directory should exist

When I run `wp makepot wp-content/plugins/hello-world`
When I run `wp i18n make-pot wp-content/plugins/hello-world`
Then the wp-content/plugins/hello-world/languages/hello-world.pot file should exist

Scenario: Uses Domain Path as destination path when none is set.
Expand All @@ -190,7 +190,7 @@ Feature: Generate a POT file of a WordPress plugin
*/
"""

When I run `wp makepot foo-plugin`
When I run `wp i18n make-pot foo-plugin`
Then STDOUT should be:
"""
Plugin file detected.
Expand Down Expand Up @@ -235,7 +235,7 @@ Feature: Generate a POT file of a WordPress plugin
__( 'wrong-domain', 'wrong-domain' );
"""

When I run `wp makepot foo-plugin`
When I run `wp i18n make-pot foo-plugin`
Then STDOUT should be:
"""
Plugin file detected.
Expand Down
24 changes: 24 additions & 0 deletions i18n-command.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

if ( ! class_exists( 'WP_CLI' ) ) {
return;
}

$autoload = __DIR__ . '/vendor/autoload.php';

if ( file_exists( $autoload ) ) {
require_once $autoload;
}

if ( class_exists( 'WP_CLI\Dispatcher\CommandNamespace' ) ) {
WP_CLI::add_command( 'i18n', '\WP_CLI\I18n\Command_Namespace' );
}

WP_CLI::add_command( 'i18n make-pot', '\WP_CLI\I18n\Makepot_Command', array(
'before_invoke' => function() {
$min_version = '5.4';
if ( version_compare( PHP_VERSION, $min_version, '<' ) ) {
WP_CLI::error( "The `wp i18n make-pot` command requires PHP {$min_version} or newer." );
}
}
) );
20 changes: 0 additions & 20 deletions makepot-command.php

This file was deleted.

17 changes: 17 additions & 0 deletions src/I18n_Namespace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace WP_CLI\I18n;

use WP_CLI\Dispatcher\CommandNamespace;

/**
* Provides internationalization tools for WordPress projects.
*
* ## EXAMPLES
*
* # Create a POT file for the WordPress plugin/theme in the current directory
* $ wp i18n make-pot . languages/my-plugin.pot
*
*/
class Command_Namespace extends CommandNamespace {
}
4 changes: 2 additions & 2 deletions src/Makepot_Command.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace WP_CLI\Makepot;
namespace WP_CLI\I18n;

use Gettext\Translation;
use Gettext\Translations;
Expand Down Expand Up @@ -56,7 +56,7 @@ class Makepot_Command extends WP_CLI_Command {
* ## EXAMPLES
*
* # Create a POT file for the WordPress plugin/theme in the current directory
* $ wp makepot . languages/my-plugin.pot
* $ wp i18n make-pot . languages/my-plugin.pot
*
* @when before_wp_load
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Pot_Generator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace WP_CLI\Makepot;
namespace WP_CLI\I18n;

use Gettext\Generators\Po;
use Gettext\Translations;
Expand Down
2 changes: 1 addition & 1 deletion src/WordPress_Code_Extractor.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace WP_CLI\Makepot;
namespace WP_CLI\I18n;

use Gettext\Extractors\PhpCode;
use Gettext\Translation;
Expand Down
2 changes: 1 addition & 1 deletion src/WordPress_Functions_Scanner.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace WP_CLI\Makepot;
namespace WP_CLI\I18n;

use Gettext\Translations;
use Gettext\Utils\PhpFunctionsScanner;
Expand Down
2 changes: 1 addition & 1 deletion wp-cli.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require:
- makepot-command.php
- i18n-command.php

0 comments on commit 93c1109

Please sign in to comment.