Skip to content

Commit 3b30830

Browse files
authored
Document migration examples in tools/migrate (#12)
1 parent a5a2cd8 commit 3b30830

File tree

10 files changed

+2038
-11
lines changed

10 files changed

+2038
-11
lines changed

tools/migrate/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Migration Tools
2+
3+
`migrate-l10n.py` is a CLI script which uses the `fluent.migrate` module under
4+
the hood to run migrations on existing translations.
5+
6+
## Examples
7+
8+
The `examples/` directory contains a number of sample migrations. To run them
9+
you'll need at least one clone of a localization repository, e.g. from
10+
https://hg.mozilla.org/l10n-central/.
11+
12+
Amend your `PYTHONPATH` to make sure that all `fluent.*` modules can be found:
13+
14+
$ export PYTHONPATH=$(pwd)/../..:$PYTHONPATH
15+
16+
Then run migrations passing the `examples` directory as the reference:
17+
18+
$ ./migrate-l10n.py --lang it --reference-dir examples --localization-dir ~/moz/l10n-central/it examples.about_dialog examples.about_downloads examples.bug_1291693
19+
20+
Here's what the output should look like:
21+
22+
Annotating /home/stas/moz/l10n-central/it
23+
Running migration examples.about_dialog
24+
Writing to /home/stas/moz/l10n-central/it/browser/about_dialog.ftl
25+
Committing changeset: Migrate about:dialog, part 1
26+
Running migration examples.about_downloads
27+
Writing to /home/stas/moz/l10n-central/it/mobile/about_downloads.ftl
28+
Committing changeset: Migrate about:download in Firefox for Android, part 1
29+
Writing to /home/stas/moz/l10n-central/it/mobile/about_downloads.ftl
30+
Committing changeset: Migrate about:download in Firefox for Android, part 2
31+
Writing to /home/stas/moz/l10n-central/it/mobile/about_downloads.ftl
32+
Committing changeset: Migrate about:download in Firefox for Android, part 3
33+
Running migration examples.bug_1291693
34+
Writing to /home/stas/moz/l10n-central/it/browser/menubar.ftl
35+
Writing to /home/stas/moz/l10n-central/it/browser/toolbar.ftl
36+
Committing changeset: Bug 1291693 - Migrate the menubar to FTL, part 1
37+
Writing to /home/stas/moz/l10n-central/it/browser/branding/official/brand.ftl
38+
Committing changeset: Bug 1291693 - Migrate the menubar to FTL, part 2
39+
Writing to /home/stas/moz/l10n-central/it/browser/menubar.ftl
40+
Writing to /home/stas/moz/l10n-central/it/browser/toolbar.ftl
41+
Writing to /home/stas/moz/l10n-central/it/browser/branding/official/brand.ftl
42+
Committing changeset: Bug 1291693 - Migrate the menubar to FTL, part 3

tools/migrate/examples/__init__.py

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
update-failed =
6+
Update failed. <label>Download the latest version</label>
7+
channel-description =
8+
You are currently on the <label>{ $channelName }</label> update channel.
9+
community =
10+
{ brand-short-name } is designed by <label>{ vendor-short-name }</label>,
11+
a <label>global community</label> working together to keep the Web
12+
open, public and accessible to all.

tools/migrate/about_dialog.py renamed to tools/migrate/examples/about_dialog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
def migrate(ctx):
1111
"""Migrate about:dialog, part {index}"""
1212

13-
ctx.add_reference('browser/aboutDialog.ftl', realpath='aboutDialog.ftl')
13+
ctx.add_reference('browser/about_dialog.ftl', realpath='about_dialog.ftl')
1414
ctx.add_localization('browser/chrome/browser/aboutDialog.dtd')
1515

16-
ctx.add_transforms('browser/aboutDialog.ftl', [
16+
ctx.add_transforms('browser/about_dialog.ftl', [
1717
FTL.Message(
1818
id=FTL.Identifier('update-failed'),
1919
value=CONCAT(
@@ -34,7 +34,7 @@ def migrate(ctx):
3434
)
3535
),
3636
FTL.Message(
37-
id=FTL.Identifier('channel-desc'),
37+
id=FTL.Identifier('channel-description'),
3838
value=CONCAT(
3939
COPY(
4040
'browser/chrome/browser/aboutDialog.dtd',
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
title = Downloads
6+
header = Your Downloads
7+
empty = No Downloads
8+
9+
open-menuitem
10+
.label = Open
11+
retry-menuitem
12+
.label = Retry
13+
remove-menuitem
14+
.label = Delete
15+
pause-menuitem
16+
.label = Pause
17+
resume-menuitem
18+
.label = Resume
19+
cancel-menuitem
20+
.label = Cancel
21+
remove-all-menuitem
22+
.label = Delete All
23+
24+
delete-all-title = Delete All
25+
delete-all-message =
26+
{ $num ->
27+
[1] Delete this download?
28+
*[other] Delete { $num } downloads?
29+
}
30+
31+
download-state-downloading = Downloading…
32+
download-state-canceled = Canceled
33+
download-state-failed = Failed
34+
download-state-paused = Paused
35+
download-state-starting = Starting…
36+
download-state-unknown = Unknown
37+
38+
download-size-unknown = Unknown size

tools/migrate/about_downloads.py renamed to tools/migrate/examples/about_downloads.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# coding=utf8
22

33
import fluent.syntax.ast as FTL
4-
from fluent.migrate import EXTERNAL_ARGUMENT, COPY, PLURALS, REPLACE
4+
from fluent.migrate import EXTERNAL_ARGUMENT, COPY, PLURALS, REPLACE_IN_TEXT
55

66

77
def migrate(ctx):
88
"""Migrate about:download in Firefox for Android, part {index}"""
99

1010
ctx.add_reference(
11-
'mobile/aboutDownloads.ftl',
12-
realpath='aboutDownloads.ftl'
11+
'mobile/about_downloads.ftl',
12+
realpath='about_downloads.ftl'
1313
)
1414
ctx.add_localization('mobile/android/chrome/aboutDownloads.dtd')
1515
ctx.add_localization('mobile/android/chrome/aboutDownloads.properties')
1616

17-
ctx.add_transforms('mobile/aboutDownloads.ftl', [
17+
ctx.add_transforms('mobile/about_downloads.ftl', [
1818
FTL.Message(
1919
id=FTL.Identifier('title'),
2020
value=COPY(
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# This Source Code Form is subject to the terms of the Mozilla Public
2-
# License, v. 2.0. If a copy of the MPL was not distributed with this
3-
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
brand-shorter-name = Firefox
66
brand-short-name = Firefox
77
brand-full-name = Mozilla Firefox
88
vendor-short-name = Mozilla
99
10-
trademark-info =
10+
trademark-info =
1111
Firefox and the Firefox logos are trademarks of the Mozilla Foundation.
1212
1313
sync-brand-short-name = Sync

0 commit comments

Comments
 (0)