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

add reverse method of extract(string) #7

Merged
merged 2 commits into from
Mar 5, 2014
Merged

add reverse method of extract(string) #7

merged 2 commits into from
Mar 5, 2014

Conversation

johnyb
Copy link
Collaborator

@johnyb johnyb commented Mar 5, 2014

during PO.parse, an extract(string) method is called on each string to
unescape some characters (like " and ). This process should be reverted
in the toString method.

The PO spec says, that all strings should be C-Strings. Otherwise tools
like msgmerge (from the gettext package) will fail parsing po files written
by this library.

There is issue #2, that would bring a new extract method to PO.parse. When merging this, the escape-method should also be adopted to reflect this.

during PO.parse, an extract(string) method is called on each string to
unescape some characters (like " and \). This process should be reverted
in the toString method.

The PO spec says, that all strings should be C-Strings. Otherwise tools
like msgmerge (from the gettext package) will fail parsing po files written
by this library.
@johnyb
Copy link
Collaborator Author

johnyb commented Mar 5, 2014

If you need real world examples of translated strings that would create broken po-files, I could add some to the tests. For now, I just added some example strings, that don’t make any sense at all.

@rubenv
Copy link
Owner

rubenv commented Mar 5, 2014

You're right, we need to correct in both ways. The attached code looks good. Do add some broken real-life cases though, those are the best regression tests we can find. Preferably a test in both directions (parse and write).

make sure, if a file containing c-string messages is identical after being
parsed and written afterwards.
@johnyb
Copy link
Collaborator Author

johnyb commented Mar 5, 2014

I added a new po file that can be used to test some real world messages containing escaped strings. For now, I just added an example that was broken in a project, I am working on.

@rubenv
Copy link
Owner

rubenv commented Mar 5, 2014

Cool, thanks, merging and pushing a release.

rubenv added a commit that referenced this pull request Mar 5, 2014
add reverse method of extract(string)
@rubenv rubenv merged commit cb12e69 into rubenv:master Mar 5, 2014
rubenv added a commit that referenced this pull request Mar 5, 2014
@rubenv
Copy link
Owner

rubenv commented Mar 5, 2014

Released 0.2.6!

@johnyb johnyb deleted the write_escaped branch March 5, 2014 12:45
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

Successfully merging this pull request may close these issues.

2 participants