Adjust line wrapping algorithm to be closer to the GNU gettext tooling
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 169
- Forks
- 48
- PR merge metrics
- No merged PRs in 30d
Description
In our project we use both tools for different parts of our translation pipeline. Unfortunately the inconsistency creates very noisy commits. Bringing them closer together will make reviewing changes made with tools relying on gettext-parser a lot easier to review.
Examples from a diff
Below are examples of a diff. On the left is a .po file created by msginit and manipulated by GNU gettext tools. On the right side is the output of a call to gettext-parser's po.compile function.

The string <b><em class=\"placeholder\">@count</em> Members</b> are selected is 65 characters long, so it's not wrapped. However the entire line msgid_plural "<b><em class=\"placeholder\">@count</em> Members</b> are selected" is 80 characters long which seems to cause the GNU tools to wrap the line.
The same happens for


<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or is 77 characters long. The GNU tools seem to allow this with the space being on the first line as the 77th character. gettext-parser will wrap one space earlier.
This seems to occur more often than expected. For example in the following lines as well.


It seems the GNU tools have a bit more knowledge of HTML while the gettext-parser treats href=\"\">[social_mentions:mentioned_user]</a> as an unbreakable string, the GNU break makes more sense because <a href=\"\"> together is more important.
A similar case for this can be found below, where the space is found to be a better breaking point than within a tag.


I also saw the following which actually suggests that the GNU tools allow 77 characters on a line so it may be a better default than 76. I couldn't find the GNU tools' line-break algorithm so I'm not sure whether they special case spaces and dots or just count to 77.

Open Social Branding will be replaced by site name (and slogan if available). is exactly 77 characters.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the gettext-parser po.compile entry point and reproduce the wrapping cases shown in the issue, comparing its output with GNU gettext tooling. Define the intended line length and breaking behavior for spaces, HTML tags, and attributes, then verify that compiled PO output matches the GNU examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- localization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100