Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
Fix Bug 1497565 - Rename locales to locales-src to avoid accidentall…
Browse files Browse the repository at this point in the history
…y exporting l10n-exposed strings (#4506)
  • Loading branch information
Mardak committed Oct 17, 2018
1 parent d9b7367 commit 0fb3f8c
Show file tree
Hide file tree
Showing 103 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
@@ -1,2 +1,2 @@
# flod as main contact for string changes
locales/en-US/strings.properties @flodolo
locales-src/en-US/strings.properties @flodolo
8 changes: 7 additions & 1 deletion bin/locales.js
@@ -1,4 +1,10 @@
exports.DEFAULT_LOCALE = "en-US";
if (!process.env.npm_lifecycle_event) {
throw Error("You should only run this from npm script contexts");
}

exports.DEFAULT_LOCALE = process.env.npm_package_config_default_locale;

exports.LOCALES_SOURCE_DIRECTORY = process.env.npm_package_config_locales_dir;

// This locales list is to find any similar locales that we can reuse strings
// instead of falling back to the default, e.g., use bn-BD strings for bn-IN.
Expand Down
6 changes: 3 additions & 3 deletions bin/strings-import.js
Expand Up @@ -7,7 +7,7 @@ const fetch = require("node-fetch");
/* globals cd, ls, mkdir, rm, ShellString */
require("shelljs/global");

const {CENTRAL_LOCALES, DEFAULT_LOCALE} = require("./locales");
const {CENTRAL_LOCALES, DEFAULT_LOCALE, LOCALES_SOURCE_DIRECTORY} = require("./locales");
const L10N_CENTRAL = "https://hg.mozilla.org/l10n-central";
const PROPERTIES_PATH = "raw-file/default/browser/chrome/browser/activity-stream/newtab.properties";
const STRINGS_FILE = "strings.properties";
Expand Down Expand Up @@ -74,9 +74,9 @@ async function saveProperties(locale) {

// Replace and update each locale's strings
async function updateLocales() {
console.log("Switching to and deleting existing l10n tree under: locales");
console.log(`Switching to and deleting existing l10n tree under: ${LOCALES_SOURCE_DIRECTORY}`);

cd("locales");
cd(LOCALES_SOURCE_DIRECTORY);
ls().forEach(dir => {
// Keep the default/source locale as it might have newer strings
if (dir !== DEFAULT_LOCALE) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions package.json
Expand Up @@ -88,21 +88,26 @@
"main": "bootstrap.js",
"repository": "mozilla/activity-stream",
"config": {
"default_locale": "en-US",
"/*": "NB: This directory is *not* 'locales' to avoid mercurial hook for uplifts.",
"**": "It contains the source default locale strings to be exported for localization",
"*/": "and is the path used to update translated strings and to prerender strings.",
"locales_dir": "locales-src",
"mc_dir": "../mozilla-central"
},
"scripts": {
"mochitest": "(cd $npm_package_config_mc_dir && ./mach mochitest browser/components/newtab/test/browser --headless)",
"mochitest-debug": "(cd $npm_package_config_mc_dir && ./mach mochitest --jsdebugger browser/components/newtab/test/browser)",
"bundle": "npm-run-all bundle:*",
"bundle:locales": "pontoon-to-json --src locales --dest data",
"bundle:locales": "pontoon-to-json --src $npm_package_config_locales_dir --dest data",
"bundle:webpack": "webpack --config webpack.system-addon.config.js",
"bundle:css": "node-sass --source-map true --source-map-contents content-src/styles -o css",
"bundle:html": "rimraf prerendered && webpack --config webpack.prerender.config.js && node ./bin/render-activity-stream-html.js",
"buildmc": "npm-run-all buildmc:*",
"prebuildmc": "rimraf $npm_package_config_mc_dir/browser/components/newtab/",
"buildmc:bundle": "npm run bundle",
"buildmc:copy": "rsync --exclude-from .mcignore -a . $npm_package_config_mc_dir/browser/components/newtab/",
"buildmc:stringsExport": "cp locales/en-US/strings.properties $npm_package_config_mc_dir/browser/locales/en-US/chrome/browser/activity-stream/newtab.properties",
"buildmc:stringsExport": "cp $npm_package_config_locales_dir/$npm_package_config_default_locale/strings.properties $npm_package_config_mc_dir/browser/locales/$npm_package_config_default_locale/chrome/browser/activity-stream/newtab.properties",
"buildmc:copyPingCentre": "cpx \"ping-centre/PingCentre.jsm\" $npm_package_config_mc_dir/browser/modules",
"startmc": "npm-run-all --parallel startmc:*",
"prestartmc": "npm run buildmc",
Expand Down
4 changes: 2 additions & 2 deletions yamscripts.yml
Expand Up @@ -14,7 +14,7 @@ scripts:

# bundle: Build all assets for activity stream
bundle:
locales: pontoon-to-json --src locales --dest data
locales: pontoon-to-json --src $npm_package_config_locales_dir --dest data
webpack: webpack --config webpack.system-addon.config.js
css: node-sass --source-map true --source-map-contents content-src/styles -o css
html: rimraf prerendered && webpack --config webpack.prerender.config.js && node ./bin/render-activity-stream-html.js
Expand All @@ -24,7 +24,7 @@ scripts:
pre: rimraf $npm_package_config_mc_dir/browser/components/newtab/
bundle: => bundle
copy: rsync --exclude-from .mcignore -a . $npm_package_config_mc_dir/browser/components/newtab/
stringsExport: cp locales/en-US/strings.properties $npm_package_config_mc_dir/browser/locales/en-US/chrome/browser/activity-stream/newtab.properties
stringsExport: cp $npm_package_config_locales_dir/$npm_package_config_default_locale/strings.properties $npm_package_config_mc_dir/browser/locales/$npm_package_config_default_locale/chrome/browser/activity-stream/newtab.properties
copyPingCentre: cpx "ping-centre/PingCentre.jsm" $npm_package_config_mc_dir/browser/modules

# startmc: Start developing the bootstrapped add-on
Expand Down

0 comments on commit 0fb3f8c

Please sign in to comment.