Fluent to Fluent Migrations

It’s possible to migrate existing Fluent messages using COPY_PATTERN in a migration recipe. Unlike migrations from legacy content, it’s not possible to interpolate the text, only to copy existing content without changes.

Consider for example a patch modifying an existing message to move the original value to a alt attribute.

Original message:

about-logins-icon = Warning icon
    .title = Breached website

New message:

about-logins-breach-icon =
    .alt = Warning icon
    .title = Breached website

This type of changes requires a new message identifier, which in turn causes existing translations to be lost. It’s possible to migrate the existing translated content with:

from fluent.migrate import COPY_PATTERN

about-logins-breach-icon =
    .alt = {COPY_PATTERN(from_path, "about-logins-icon")}
    .title = {COPY_PATTERN(from_path, "about-logins-icon.title")}

In this specific case, the destination and source files are the same. The dot notation is used to access attributes: about-logins-icon.title matches the title attribute of the message with identifier about-logins-icon, while about-logins-icon alone matches the value of the message.


Using the message identifier in COPY_PATTERN will not migrate the message as a whole, with all its attributes, only its value.