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

lint:po - lint locale/*.po files to ensure same vars and components ({foo}, {0}, <0>, <0 />, </0>) #1144

Merged
merged 5 commits into from
Dec 13, 2021

Conversation

himdel
Copy link
Collaborator

@himdel himdel commented Oct 29, 2021

Fixes AAH-804

Quick and dirty *.po linter to check for common problems.

Right now, this will catch msgid/msgstr pairs with a different set of varible names, or components...

$ cat problem.po
msgid "Hello {name}"
msgstr "Bonjour {nom}"

$ npm run lint:po
...
Difference between msgid="Hello {name}" and msgstr="Bonjour {nom}":
  Missing from msgstr: {name}
  Unexpected in msgstr: {nom}
  at problem.po:2

Related to #1143 (comment) (and thus #810)

And enabling on github actions, which should consequenty fail with the current fr.po problems :)

(see image below)


Ended up moving the code to https://github.com/himdel/lint-po/, and releasing to pip as https://pypi.org/project/lint-po/ .
Backend PR ansible/galaxy_ng#1071

@himdel
Copy link
Collaborator Author

himdel commented Nov 16, 2021

Added a github actions error formatting, fixed the line numbers, removed the package.json for loop and rewritten in ruby...

20211116013247

himdel added a commit to himdel/lint-po that referenced this pull request Nov 24, 2021
himdel added a commit to himdel/lint-po that referenced this pull request Dec 5, 2021
himdel added a commit to himdel/lint-po that referenced this pull request Dec 5, 2021
* support filenames
* support python %(foo)s format strings
* add github action error formatter
* use line number of the first line of msgstr
and python \w+ also matches `opération`
fix acceented chars, decouple error reporting from processing, DRY up state handling

`\w+` -> `[\p{Alpha}\p{Number}_]` & `/u`
easiest way to share between repos

`pip install lint-po`
@himdel himdel force-pushed the lint-po branch 2 times, most recently from 7869632 to 234f846 Compare December 5, 2021 01:59
himdel added a commit to ansible/galaxy_ng that referenced this pull request Dec 7, 2021
…1071)

and re-run `plugin-template --github galaxy_ng` from https://github.com/pulp/plugin_template

lint-po is https://pypi.org/project/lint-po/ , related to ansible/ansible-hub-ui#1144

(post-job-template seems to get evaluated with two spaces before the first line, so using an empty line to get both tasks at the same level)

Issue: AAH-804
patchback bot pushed a commit to ansible/galaxy_ng that referenced this pull request Dec 7, 2021
…1071)

and re-run `plugin-template --github galaxy_ng` from https://github.com/pulp/plugin_template

lint-po is https://pypi.org/project/lint-po/ , related to ansible/ansible-hub-ui#1144

(post-job-template seems to get evaluated with two spaces before the first line, so using an empty line to get both tasks at the same level)

Issue: AAH-804
(cherry picked from commit 8adcc34)
@himdel himdel added the backport-4.4 This PR should be backported to stable-4.4 (2.1) label Dec 7, 2021
himdel added a commit to ansible/galaxy_ng that referenced this pull request Dec 7, 2021
…1071) (#1073)

and re-run `plugin-template --github galaxy_ng` from https://github.com/pulp/plugin_template

lint-po is https://pypi.org/project/lint-po/ , related to ansible/ansible-hub-ui#1144

(post-job-template seems to get evaluated with two spaces before the first line, so using an empty line to get both tasks at the same level)

Issue: AAH-804
(cherry picked from commit 8adcc34)

Co-authored-by: Martin Hradil <mhradil@redhat.com>
@himdel himdel marked this pull request as ready for review December 7, 2021 23:57
@himdel himdel closed this Dec 7, 2021
@himdel himdel reopened this Dec 7, 2021
@himdel himdel requested a review from ZitaNemeckova December 8, 2021 00:05
@himdel himdel merged commit 05bbe11 into ansible:master Dec 13, 2021
@himdel himdel deleted the lint-po branch December 13, 2021 14:50
@patchback
Copy link

patchback bot commented Dec 13, 2021

Backport to stable-4.4: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-4.4/05bbe11e7866d21a916672a8762794fef5abc874/pr-1144

Backported as #1369

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Dec 13, 2021
…`{foo}`, `{0}`, `<0>`, `<0 />`, `</0>`) (#1144)

* lint:po - lint locale/*.po files to ensure same vars and components ({foo}, {0}, <0>, <0>, </0>)

* lint:po - convert to ruby

* support filenames
* support python %(foo)s format strings
* add github action error formatter
* use line number of the first line of msgstr

* lint:po - convert to python

and python \w+ also matches `opération`

* lint:po - convert to js

fix acceented chars, decouple error reporting from processing, DRY up state handling

`\w+` -> `[\p{Alpha}\p{Number}_]` & `/u`

* lint:po - use released pip package instead of a local script

easiest way to share between repos

`pip install lint-po`

(cherry picked from commit 05bbe11)
himdel added a commit that referenced this pull request Dec 13, 2021
…`{foo}`, `{0}`, `<0>`, `<0 />`, `</0>`) (#1144) (#1369)

* lint:po - lint locale/*.po files to ensure same vars and components ({foo}, {0}, <0>, <0>, </0>)

* lint:po - convert to ruby

* support filenames
* support python %(foo)s format strings
* add github action error formatter
* use line number of the first line of msgstr

* lint:po - convert to python

and python \w+ also matches `opération`

* lint:po - convert to js

fix acceented chars, decouple error reporting from processing, DRY up state handling

`\w+` -> `[\p{Alpha}\p{Number}_]` & `/u`

* lint:po - use released pip package instead of a local script

easiest way to share between repos

`pip install lint-po`

(cherry picked from commit 05bbe11)

Co-authored-by: Martin Hradil <mhradil@redhat.com>
@github-actions github-actions bot added the backported-4.4 This PR has been backported to stable-4.4 (2.1) label Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-4.4 This PR should be backported to stable-4.4 (2.1) backported-4.4 This PR has been backported to stable-4.4 (2.1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants