Closed Bug 1459619 Opened 6 years ago Closed 6 years ago

Allow substitutions in transforms_from

Categories

(Localization Infrastructure and Tools :: Fluent Migration, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: stas, Assigned: stas)

Details

Attachments

(1 file)

Bug 1457948 has a good example of what a migration recipe may look like when the transforms_from helper from bug 1452107 is used. See attachment 8973425 [details].

I wonder if we can do even better, in particular when it comes to the long path names passed into COPY:

permissions-invalid-uri-title = { COPY("browser/chrome/browser/preferences/preferences.properties", "invalidURITitle") }
permissions-invalid-uri-label = { COPY("browser/chrome/browser/preferences/preferences.properties", "invalidURI") }

Flod suggested we use variables: COPY($preferences_properties, "invalidURITitle").

I generalized this idea a bit to allow passing custom functions to transforms_from. This way, the processing logic doesn't have to be hardcoded in fluent.migrate.
Assignee: nobody → stas
I'm torn on this one.

I wonder if we really want a generic approach here, or just another common case handled sweet? That's what I like about transforms_from, it's doing one job well.

My counter-proposal would be to add a keyword argument from_path to transforms_from, which is used by the COPY() inspection code if only one argument is given?

transforms_from('''\
permissions-invalid-uri-title = { COPY("invalidURITitle") }
permissions-invalid-uri-label = { COPY("invalidURI") }
permissions-other-label = { COPY("browser/chrome/browser/preferences/other.properties", "invalidURI") }
''', from_path="browser/chrome/browser/preferences/preferences.properties")

The idea being that most often, these simple conversion are done from one or two files to another, so you can do two blocks.

That feels more straightforward. I'm not perfectly happy with the magic-COPY-nargs, but I'm also not too concerned.

With the current approach, we'll sprinkle COPY_KEY() in many places, I'm afraid.

Stas?
Flags: needinfo?(stas)
I like it! I'll amend the patch on Monday. Thanks, Axel!
Flags: needinfo?(stas)
Comment on attachment 8973686 [details]
Bug 1459619 - Allow substitutions in transforms_from.

Axel Hecht [:Pike] has approved the revision.

https://phabricator.services.mozilla.com/D1149
Attachment #8973686 - Flags: review+
Attachment #8973686 - Attachment description: Bug 1459619 - Allow custom transform functions in transforms_from. r?Pike → Bug 1459619 - Allow substitutions in transforms_from.
Landed in https://hg.mozilla.org/l10n/fluent-migration/rev/bf862d2e0624.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Summary: Allow custom transform functions in transforms_from → Allow substitutions in transforms_from
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: