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

Never migrate partial translations #44

Merged
merged 1 commit into from
Feb 6, 2018

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Feb 5, 2018

Partial translations may break the AST because they produce TextElements with None values. For now, explicitly skip any transforms which depend on at least one missing legacy string.

In the future we might be able to allow partial migrations in some situations, like migrating a subset of attributes of a message. See https://bugzilla.mozilla.org/show_bug.cgi?id=1321271.

@stasm
Copy link
Contributor Author

stasm commented Feb 5, 2018

Also cc @flodolo. I ran the migration from bug 1424682 on all locales and encountered no errors. Granted, it means that some partial translations for some old inactive locales might be lost in the migration.

@flodolo
Copy link
Contributor

flodolo commented Feb 5, 2018

Granted, it means that some partial translations for some old inactive locales might be lost in the migration.

I think that's fine.

@stasm
Copy link
Contributor Author

stasm commented Feb 5, 2018

Yes, that's my thinking as well. I think we should prioritize being able to run migrations without errors over migrating strict 100% of what could be salvaged.

@flodolo
Copy link
Contributor

flodolo commented Feb 5, 2018

Confirming that migration runs without errors with this patch applied.

Note: this creates files with message references that are not actually available. For example:

category-general
    .tooltiptext = { pane-general-title }

But compare-locales catches those as WARNINGs, even if the message is a bit misleading:

WARNING: Obsolete message reference: SOMEREFERENCE at line X, column Y for STRINGID

@Pike
Copy link
Contributor

Pike commented Feb 6, 2018

@flodolo, can you file bugs on each issue? Better wording, and message references to non-existing messages?

@stasm
Copy link
Contributor Author

stasm commented Feb 6, 2018

Note: this creates files with message references that are not actually available. For example:

   category-general
       .tooltiptext = { pane-general-title }

This isn't caused by this patch. It's because the migration spec creates this message from nothing:

FTL.Message(
    id = FTL.Identifier('category-general'),
    attributes = [
        FTL.Attribute(
            FTL.Identifier('tooltiptext'),
            FTL.Pattern(
                elements = [
                    FTL.Placeable(
                        expression = FTL.MessageReference(
                            id = FTL.Identifier(
                                'pane-general-title'
                            )
                        )
                    )
                ]
            )
        )
    ]
)

In this case, nothing is supposed to be migrated. I don't think the migration code should check if the message has references and if they point to an existing messages (which is likely impossible to establish with certainty).

@flodolo
Copy link
Contributor

flodolo commented Feb 6, 2018

@flodolo, can you file bugs on each issue? Better wording, and message references to non-existing messages?

Filed a bug for the first part, not sure I get the second. Is it about being able to fall back to English at run-time for them, or about the migration?

Filed also

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'm not happy with how we test this. I've filed bug 1436014 on that.

Please remove the duplicated tests, and also nitpick on the docstrings a bit now. Happy to help with the rest later.

{}
)

def test_missing_string_in_one_of_attributes(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate, too.

{}
)

def test_missing_string_in_only_attribute(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate test, copy-n-paste error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks. I must have accidentally pasted twice.

# Make sure all the dependencies are present in the current
# changeset. Partial migrations are not currently supported.
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1321271
available_deps = message_deps & changeset
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd love to see some of this reflected in the docstrings of either merge_context or in_changeset. Re-reading both, I wonder if it'd be good to balance the two, for merge_context describing what it does in more detail, and in_changeset describing potential implementation details. Sounds like out-of-scope for this patch, but good docstrings help review. PS: I like the commit message, which I can't say on pr reviews :-(

Partial translations may break the AST because they produce `TextElements` with
`None` values. For now, explicitly skip any transforms which depend on at least
one missing legacy string.

In the future we might be able to allow partial migrations in some situations,
like migrating a subset of attributes of a message. See
https://bugzilla.mozilla.org/show_bug.cgi?id=1321271.
@stasm stasm merged commit e208161 into projectfluent:master Feb 6, 2018
@stasm stasm deleted the never-merge-partial branch February 6, 2018 16:26
@stasm stasm added this to the python-fluent 0.6.1 milestone Feb 6, 2018
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.

3 participants