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

Follow GNU .po files headers formatting #251

Closed
NathanBnm opened this issue Feb 24, 2020 · 9 comments
Closed

Follow GNU .po files headers formatting #251

NathanBnm opened this issue Feb 24, 2020 · 9 comments

Comments

@NathanBnm
Copy link
Contributor

Is there a way to follow the recommended gnu headers for .po files as following? With the copyright header and description.

# SOME DESCRIPTIVE TITLE
# Copyright (C) YEAR Free Software Foundation, Inc.
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2008-02-06 16:25-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
@oscarotero
Copy link
Member

I think there's no way to insert this comment before the headers right now. But it's easy to implement. I imagine something like this:

$translations->setDescription(<<<EOT
SOME DESCRIPTIVE TITLE
Copyright (C) YEAR Free Software Foundation, Inc.
This file is distributed under the same license as the PACKAGE package.
FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
EOT);

I don't know whether adding flags to the headers makes sense (fuzzy).

@NathanBnm
Copy link
Contributor Author

Sure it could be a great feature 😄

I don't know whether adding flags to the headers makes sense (fuzzy).

It makes sense because it's used to notice the translators that one or more translations in the file are fuzzy, without having to scroll down all the file.

@oscarotero
Copy link
Member

Ok, where did you see this example?

@NathanBnm
Copy link
Contributor Author

NathanBnm commented Feb 25, 2020

You can see specifications here: https://www.gnu.org/software/trans-coord/manual/gnun/html_node/PO-Header.html

For further info: https://www.gnu.org/software/gettext/manual/html_node/index.html

Some of these specifications could be adapted or removed to fit better with your scripts.
But I think the comments before the header, the "Po-Revision-Date" and the "Content-Type" are useful to implement. Setting the "Last-Translator" field could be great too. By default it should be "Automatically generated" (same for "FIRST AUTHOR" in comments before the header).

@oscarotero
Copy link
Member

New version released including these features:

$translations->setDescription($description);
$translations->getFlags()->add('fuzzy');

@NathanBnm
Copy link
Contributor Author

@oscarotero is there a possibility to add the fuzzy flag automatically? I mean when a translation has been changed, it is erased from the PO file. The issue is that sometimes it's just a little difference like a colon or a single word. It would be great not to erase completly the concerning translation but mark it as fuzzy when there are a few changes to the string.

@oscarotero
Copy link
Member

I don't understand. Do you mean the Translations class handles the flags automatically according to the flags added in each translation? This class should contain the less logic (aka magic) possible, so anyone can edit the content, add or remove flags according to his own standards.

@NathanBnm
Copy link
Contributor Author

Yes but it would be an option, maybe a new Merge method.

@oscarotero
Copy link
Member

Currently, the translations flags are using the same option as the individual translation (https://github.com/php-gettext/Gettext/blob/master/src/Translations.php#L188)

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

No branches or pull requests

2 participants