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

Duplicate translations #25

Merged
merged 2 commits into from
May 26, 2015
Merged

Duplicate translations #25

merged 2 commits into from
May 26, 2015

Conversation

whatyouhide
Copy link
Contributor

This PR handles duplicate translations. The implementation of the function that checks for duplicates uses throw/catch in order to traverse the list of translations only one but the code is very simple and straightforward, so that should not be a problem. Thanks @josevalim for the help!

This commit introduces checks for duplicate translations when parsing PO files.
Duplicate translations will result in a parse error.
This function now uses throw/catch in order to traverse a list of
translations only once to find duplicates. The code is very contained
and straightforward, so throw/catch shouldn't be a problem here.

The upside of doing this is speed and simplicity; the downside, however,
is that we only find the first duplicate of a translation (instead of
all the duplicates of that translation). For now, this is fine since
duplicate translations should be a not very common case.
whatyouhide added a commit that referenced this pull request May 26, 2015
@whatyouhide whatyouhide merged commit 0858410 into master May 26, 2015
@whatyouhide whatyouhide deleted the duplicate-translations branch May 26, 2015 13:43
:ok
catch
{old_line, line} ->
{:error, line, "found duplicate of this translation on line #{old_line}"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include the msgid in the error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josevalim We could, of course :) do you think very long msgids could be a problem?

edit maybe we can truncate them with ...?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whatyouhide yeah, we could show just the first line and truncate with ... if more than one. Another idea is to do this:

"found duplicate on line #{old_line} for msgid: #{the whole message id}"

If it is at the end, it is not such a big problem to be long.

@josevalim
Copy link
Contributor

👍

@whatyouhide whatyouhide mentioned this pull request May 26, 2015
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.

None yet

2 participants