Skip to content
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

Plugin headers #11

Open
ipajen opened this issue Nov 5, 2024 · 12 comments
Open

Plugin headers #11

ipajen opened this issue Nov 5, 2024 · 12 comments

Comments

@ipajen
Copy link

ipajen commented Nov 5, 2024

Question.
It doesn’t seem to extract plugin headers from The main.php file. Would it be possible?

I see from another plugin it does this and I think it would be of value that those are included for translation

ex:

Plugin URI:
description:

thanks!

@toolstack
Copy link
Owner

Possible yes, but what would the purpose be?

The headers aren't displayed to the end user or through any translation api.

@ipajen
Copy link
Author

ipajen commented Nov 5, 2024

At /wp-admin/plugins.php there is plugin information.

@toolstack
Copy link
Owner

That's part of the wordpress codebase/translation system, not part of the code of the plugin itself. They are managed as sperate projects in the main wordpress glotpress implementation.

@ipajen
Copy link
Author

ipajen commented Nov 5, 2024

Sorry if I was unclearly
It’s for a plugin not in WP repo at all.
IMG_8574

@toolstack
Copy link
Owner

I understood what you meant, but what I'm saying is that while the plugins page does use the readme for this info (not the plugin header as far as I know), it's not part of the plugin translation project, it's part of the main wordpress codebase.

There's never a time when the plugin would use these translations, hence why they are in a separate project in the wordpress glotpress instance, and have a separate translation file that is downloaded by wordpress for them.

@ipajen
Copy link
Author

ipajen commented Nov 5, 2024

True the plugin it self doesn’t use them. But WordPress does. if the plugin is not hosted on WordPress they will not get the translations. But it works to get it translated if they are included in the plugins language .po file for a GitHub only hosted. 🙏

for example:
“```
#. Description of the plugin
msgid "Update plugins and themes for WordPress."
msgstr "Aktualisiert Plugins und Themes für WordPress."


@toolstack
Copy link
Owner

In that case you'd have to grab the readme parser that wp.org uses to parse the text and break it up as required as part of the extraction process.

Not something I'd spend time on but would accept a PR if someone wanted to add it.

@ipajen
Copy link
Author

ipajen commented Nov 6, 2024

Ok. I’m not sure the information comes from the README file. When I’m testing, I find the information in the main.php file rather than in the README.

@ipajen
Copy link
Author

ipajen commented Nov 6, 2024

Just to be sure I asked AI.

In WordPress, the plugin descriptions shown in the Plugins page (wp-admin/plugins.php) come from the header comments at the top of each plugin's main file (often named main.php, but it can vary). These comments are in a specific format that WordPress reads to display information about the plugin.

Key Fields WordPress Uses

  • Plugin Name: The name of the plugin.
  • Description: A brief description, which is shown under the plugin name on the Plugins page.
  • Version: The plugin’s version number.
  • Author: The name of the plugin author.
  • Plugin URI and Author URI: URLs to the plugin’s webpage and author’s profile (optional).

These details are parsed from the file, and WordPress uses them to populate the plugin list in the Plugins admin page.

@toolstack
Copy link
Owner

Don't trust AI for, well, anything😉 While it may be true for where the plugin list gets the source strings, it probably isn't where the translations come from.

Either way, if you want to track it down and submit a PR feel free, but otherwise I'm not pursing this at this time.

@toolstack
Copy link
Owner

I did a little more investigation on this, and wp.org doesn't ship those strings in the plugin translation file, so I don't think we should either.

However, a work around would be to create a "extra-strings.php" file in your plugin, do a simple _("string") line for each of the header lines you want trasnlated, and let gp auto extract pick them up. Then just don't ship the extra-strings.php in your release file (or do... no real harm).

@ipajen
Copy link
Author

ipajen commented Nov 11, 2024

Thank you. but I found a work around using https://developer.wordpress.org/cli/commands/i18n/make-pot/ where it creates the strings in the plugin translation file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants