Skip to content

Bug 1366298 - Skip SelectExpression in PLURALS for one plural category #27

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

Merged
merged 1 commit into from
Nov 9, 2017

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Nov 8, 2017

https://bugzilla.mozilla.org/show_bug.cgi?id=1366298

Languages with one plural category can have their translations migrated
directly to a single Pattern rather than a SelectExpression with one
variant. This will only happen when the number of variants in the
legacy translation is also one.

This also adds tests for languages with more categories than en-US.


# A special case for languages with one plural category. We don't need
# to insert a SelectExpression at all for them.
if len(keys) == len(variants) == 1:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The special case is only triggered when both the number of plural categories in CLDR and the number of variants in the legacy translation are 1.

If the legacy translation has more variants we will still insert a SelectExpression: https://github.com/projectfluent/python-fluent/pull/27/files#diff-6d4522d85d5c0eb1cbe1e024d2407986R69

@stasm stasm requested a review from Pike November 8, 2017 11:55
Copy link
Contributor

@Pike Pike left a comment

Choose a reason for hiding this comment

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

I think my comment about the test name holds true for most of the file here.

I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1415555 with some suggestions on how to evolve the tests here.



@unittest.skipUnless(PropertiesParser, 'compare-locales required')
class TestPluralManyCategoriesWithReplace(MockContext):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you rename the test? Right now, this is test_plural.TestPluralManyCategoriesWithReplace.test_plural.

One plural is enough, how about TestManyCategories.test_with_replace()?

That said, this test sounds more like a test for the upcoming patch about strictly matching plural forms between toolkit and cldr?

Languages with one plural category can have their translations migrated
directly to a single Pattern rather than a SelectExpression with one
variant.  This will only happen when the number of variants in the
legacy translation is also one.

This also adds tests for languages with more categories than en-US.
@stasm stasm force-pushed the 1366298-migrate-plural-tests branch from 2f0b34c to a0cda4c Compare November 9, 2017 11:54
@stasm stasm merged commit 3d7b838 into projectfluent:master Nov 9, 2017
@stasm stasm deleted the 1366298-migrate-plural-tests branch November 9, 2017 11:57
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