-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WordPress Core support #69
Conversation
Here's the output of the WP-CLI command and makepot.zip The POT files for continents and cities have the same number of strings (524). The others seem to differ quite a bit. Tested both with current WordPress master/trunk
I took the numbers on the right from translate.wordpress.org as the local output with Perhaps @ocean90 can help me find the cause for this :-) |
Instead of the nightly build I ran this now against 4.9.8 as downloaded straight from WordPress.org/download. The numbers are much better now:
Administration now includes Hello Dolly (as does |
So, the reason for the difference between the admin files seems to be that It uses the
I'm not sure this is something that could or should be done within this command. I think if WordPress.org is going to use the WP-CLI command at some point for string extraction, they might add a little wrapper script around it to use |
Instead of using |
@schlessera So you'd pass a file name to Then we could use something like this: wp i18n make-pot /path/to/wordpress/core /path/to/target/wp-admin.pot \
--exclude="wp-admin/network/*,wp-admin/network.php,wp-admin/includes/class-wp-ms*,wp-admin/includes/network.php,wp-admin/includes/continents-cities.php" \
--include="wp-admin/*" \
--merge="/path/to/target/hello-dolly.pot" \
--deduplicate="/path/to/target/wp-frontend.pot" \
--package-name="WordPress" \
--copyright-holder="WordPress" \
--debug \
--skip-js \
--ignore-domain |
I'm not sure, I ignore how the files relate to each other in detail, and what will be considered the source of truth. But generally, if you have a |
Hmm, I see the problem now. What you need is not deduplication, but set operations like union and most of all intersection. |
I added an experimental You can pass one or more exceptions. The command extracts all strings from them and compares them against the ones found by the command. Strings that are contained in the exception list will be removed from final output. This way, I got the resulting POT file for wp-admin down to 2733 strings (compared to 2981 before). |
Alright, got it down to 2647! That's only 2 differences. Note regarding exceptions: this might be useful as a new merge flag in the upstream gettext library instead, see https://github.com/oscarotero/Gettext#merge-translations. |
I'm not sure why, but the output generated by
I can't find these strings on https://translate.wordpress.org either. Sounds like a bug to me and a reason why this command here should be used instead :-) |
Updated and final numbers:
I feel like now we only need to discuss the wording of the newly added arguments or, in the case of the copyright notice, the usefulness of these. |
Regarding the |
README.md
Outdated
[--merge[=<file>]] | ||
Existing POT file file whose content should be merged with the extracted strings. | ||
[--merge[=<files>]] | ||
One or more existing POT files whose contents should be merged with the extracted strings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The syntax for multiple files should be documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean documented like <file1,file2>
or as an example in the argument description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the best way is, as you have multiple arguments with the same issue.
Maybe a small adjective like comma-separated
and then a general note in the command description might be clearer?
[--merge[=<file[,file2,...]>]]
Comma-separated list of POT files whose contents should be merged with the extracted strings.
Something like that, maybe? Unsure about the notation...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out something like [--merge[=<file[,file2,...]>]]
isn't valid.
I'll stick with the description though.
README.md
Outdated
If left empty, defaults to the destination POT file. | ||
|
||
[--except=<files>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As already commented, I think --subtract
would be a clearer name.
Also, syntax for multiples files should be documented.
README.md
Outdated
[--except=<files>] | ||
If set, only strings not already existing in one of the passed POT files will be extracted. | ||
|
||
[--include=<paths>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntax for multiple paths needs to be documented.
""" | ||
<?php | ||
|
||
__( 'Hello World' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A regular project would normally use regular gettext with single underscore: _()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add both, although I don‘t think we should enphasise support for any regular, non-WP gettext project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was more about having an example that is technically correct. Outside of WordPress, __()
would normally not exist.
src/MakePotCommand.php
Outdated
$this->slug = Utils\get_flag_value( $assoc_args, 'slug', Utils\basename( $this->source ) ); | ||
$this->skip_js = Utils\get_flag_value( $assoc_args, 'skip-js', $this->skip_js ); | ||
$this->headers = Utils\get_flag_value( $assoc_args, 'headers', $this->headers ); | ||
$this->package_name = Utils\get_flag_value( $assoc_args, 'package-name', 'Unknown' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the package and copyright holder be optional?
If I understand correctly, this will now always be added, but with values of 'Unknown'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could either make it optional, change the wording (just „Copyright 2018“ without any author or name) or remove it completely. I‘m not sure if it really serves any purpose.
Also, two command arguments just for this comment is a bit too much I think. Perhaps we could go with a singular argument to manually override that line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, something more generic like --file-comment
might be preferable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #47 (comment) and #55 for previous discussion about a --comment
/ --file-comment
argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think --comment
could be ambiguous, as it could just as well refer to a translator comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added --file-comment
but left package-name
as it's needed/useful for the Project-Id-Version
POT header.
It‘s certainly not ideal, yes. I have yet to come up with a better name. Subtract could work. |
🎉 |
@swissspidy Regarding the two "Table prefix" strings that makepot missed, it might be because they were malformed. See https://core.trac.wordpress.org/changeset/43205. |
Changes in this PR:
--merge
--exclude
(see Ignore minified JavaScript files #45)--include
argument as an addition to--exclude
--copyright-holder
and--package-name
argumentsThese values are used for the copyright notice comment at the top of the POT file.
The naming of the arguments and the usefulness of that comment as a whole should be discussed.
--except
--subtract
option that accepts one or more POT filesStrings that are on this "blacklist" won't be extracted
To do:
The following commands can be used to generate the necessary POT files for WordPress core.
Note: the
Report-Msgid-Bugs-To
URL can be overridden using the--header
argument.Continents & Cities
WordPress (Development 4.9.x on translate.wordpress.org)
Administration
This one involves some more steps as it should include all files except for WordPress and Network Admin files. Also, the Hello Dolly plugin, which is bundled with WordPress core, needs to be translated as well.
Network Admin
Fixes #36.
Fixes #45.