Skip to content

Commit

Permalink
Copy Pontoon-friendly L10n resources to SDK add-on friendly paths
Browse files Browse the repository at this point in the history
- Move add-on locales to Pontoon-friendly paths

- Gulp task to copy Pontoon-friendly resources to add-on friendly paths

- Update add-on build in CircleCI to run the gulp task

- Update .gitignore

- Update docs

Fixes mozilla#557
  • Loading branch information
lmorchard committed Nov 7, 2016
1 parent ae824b1 commit b9cfcc8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# Files to ignore in the base directory
coverage
.coverage
debug-config.json
.env
MANIFEST
Expand All @@ -25,4 +26,5 @@ tmp/
# Files to ignore within specific directories
addon/*.rdf
addon/*.xpi
addon/locale/
legal-copy/*html
16 changes: 11 additions & 5 deletions addon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,29 @@ A relatively easy path for working on this addon involves the following steps:

1. Install [Firefox Developer Edition][devedition].

2. Install the [DevPrefs][devprefs] Add-on, which sets a number of preferences
1. Install the [DevPrefs][devprefs] Add-on, which sets a number of preferences
necessary for Add-on development, importantly `xpinstall.signatures.required`
and `xpinstall.whitelist.required`.

3. Install the [Extension Auto-Installer][autoinstaller] Add-on in Firefox
1. Install the [Extension Auto-Installer][autoinstaller] Add-on in Firefox
Developer Edition.

4. Run `npm start` to fire up a watcher that will build the Test Pilot add-on
whenever files change and auto-update the installed version in Firefox.
1. In the top-level directory, run `npm run addon:locales` to copy over
translated string resources into the add-on project. [If you have the frontend
web server running][quickstart], this should be automatically handled by gulp.

5. Read all about [setting up an extension development
1. In the `addon/` directory, run `npm start` to fire up a watcher that will
build the Test Pilot add-on whenever files change and auto-update the
installed version in Firefox.

1. Read all about [setting up an extension development
environment][extensiondev] on MDN.

[devedition]: https://www.mozilla.org/en-US/firefox/developer/
[devprefs]: https://addons.mozilla.org/en-US/firefox/addon/devprefs/
[autoinstaller]: https://addons.mozilla.org/en-US/firefox/addon/autoinstaller/
[extensiondev]: https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment
[quickstart]: ../docs/development/quickstart.md

For UI hacking you can run `npm run watch-ui` to easily debug `lib/templates.js` and `data/panel.css`

Expand Down
15 changes: 15 additions & 0 deletions addon/tasks/locales.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const gulp = require('gulp');
const rename = require('gulp-rename');

gulp.task('addon-copy-locales', () =>
gulp.src('./locales/**/addon.properties')
.pipe(rename(path => {
// Transform {LOCALE}/addon.properties -> {LOCALE}.properties
path.basename = path.dirname;
path.dirname = '';
}))
.pipe(gulp.dest('./addon/locale'))
);

gulp.task('addon-watch-locales', () =>
gulp.watch('./locales/**/addon.properties', ['addon-copy-locales']));
1 change: 1 addition & 0 deletions bin/circleci/build-addon.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
set -ex
npm run addon:locales
cd addon/
# only sign when on master branch or a tag
if [[ $CIRCLE_PROJECT_USERNAME == 'mozilla' && ($CIRCLE_BRANCH == 'master' || $CIRCLE_TAG != '') ]]; then
Expand Down
4 changes: 4 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ require('./frontend/tasks/pages');
require('./frontend/tasks/server');
require('./frontend/tasks/dist');

require('./addon/tasks/locales');

gulp.task('clean', () => del([
config.DEST_PATH,
config.DIST_PATH,
config.DJANGO_OLD_STATIC
]));

gulp.task('build', [
'addon-copy-locales',
'content-build',
'scripts-build',
'styles-build',
Expand All @@ -34,6 +37,7 @@ gulp.task('build', [
]);

gulp.task('watch', [
'addon-watch-locales',
'self-watch',
'content-watch',
'scripts-watch',
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"test": "cd frontend && mocha --require babel-register --require test-setup.js --recursive",
"test:ci": "NODE_ENV=test nyc mocha --recursive --reporter mocha-junit-reporter --require frontend/test-setup.js frontend/test",
"test:watch": "npm test -- --watch",
"coverage": "NODE_ENV=test nyc mocha --recursive --require frontend/test-setup.js frontend/test"
"coverage": "NODE_ENV=test nyc mocha --recursive --require frontend/test-setup.js frontend/test",
"addon:locales": "gulp addon-copy-locales"
}
}

0 comments on commit b9cfcc8

Please sign in to comment.