Skip to content

Commit

Permalink
Rename 'incognito' to 'private' when rebasing chromium strings
Browse files Browse the repository at this point in the history
  • Loading branch information
petemill authored and bbondy committed Nov 15, 2018
1 parent 8074ff6 commit 8956837
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build/commands/lib/chromiumRebaseL10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const config = require('../lib/config')
const util = require('../lib/util')
const {rebaseBraveStringFilesOnChromiumL10nFiles, braveAutoGeneratedPaths} = require('./l10nUtil')

const chromiumRebaseL10n = (options) => {
rebaseBraveStringFilesOnChromiumL10nFiles()
const chromiumRebaseL10n = async (options) => {
await rebaseBraveStringFilesOnChromiumL10nFiles()
braveAutoGeneratedPaths.forEach((sourceStringPath) => {
const cmdOptions = config.defaultOptions
cmdOptions.cwd = config.projects['brave-core'].dir
Expand Down
42 changes: 31 additions & 11 deletions build/commands/lib/l10nUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,38 @@ module.exports.allBravePaths = module.exports.braveNonGeneratedPaths.concat(modu
// This is because only 1 xtb is created per grd per locale even if it has multiple grdp files.
module.exports.braveTopLevelPaths = module.exports.allBravePaths.filter((x) => ['grd', 'json'].includes(x.split('.').pop()))


// This simply reads Chromium files that are passed to it and replaces branding strings
// with Brave specific branding strings.
// Do not use this for filtering XML, instead use chromium-rebase-l10n.py.
// Only add idempotent replacements here (i.e. don't append replace A with AX here)
module.exports.rebaseBraveStringFilesOnChromiumL10nFiles = (path) =>
Object.entries(chromiumToAutoGeneratedBraveMapping).forEach(([sourcePath, destPath]) =>
fs.writeFileSync(destPath,
fs.readFileSync(sourcePath, 'utf8')
.replace(/Automatically send usage statistics and crash reports to Google/g, 'Automatically send crash reports to Google')
.replace(/Automatically sends usage statistics and crash reports to Google/g, 'Automatically sends crash reports to Google')
.replace(/The Chromium Authors/g, 'Brave Software Inc')
.replace(/Google Chrome/g, 'Brave')
.replace(/Chromium/g, 'Brave')
.replace(/Chrome/g, 'Brave')
.replace(/Google/g, 'Brave'), 'utf8'))
module.exports.rebaseBraveStringFilesOnChromiumL10nFiles = async function (path) {
const ops = Object.entries(chromiumToAutoGeneratedBraveMapping).map(async ([sourcePath, destPath]) => {
let contents = await new Promise(resolve => fs.readFile(sourcePath, 'utf8', (err, data) => resolve(data)))
for (const replacement of defaultReplacements) {
contents = contents.replace(replacement[0], replacement[1])
}
await new Promise(resolve => fs.writeFile(destPath, contents, 'utf8', resolve))
})
await Promise.all(ops)
}

// Straight-forward string replacement list.
// Consider mapping chromium resource ID to a new brave resource ID
// for whole-message replacements, instead of adding to this list.
const defaultReplacements = [
[/Automatically send usage statistics and crash reports to Google/g, 'Automatically send crash reports to Google'],
[/Automatically sends usage statistics and crash reports to Google/g, 'Automatically sends crash reports to Google'],
[/The Chromium Authors/g, 'Brave Software Inc'],
[/Google Chrome/g, 'Brave'],
[/Chromium/g, 'Brave'],
[/Chrome/g, 'Brave'],
[/Google/g, 'Brave'],
[/You're incognito/g, 'This is a private window'],
[/an incognito/g, 'a private'],
[/an Incognito/g, 'a Private'],
[/incognito/g, 'private'],
[/Incognito/g, 'Private'],
[/inco\&amp\;gnito/g, '&private'],
[/Inco\&amp\;gnito/g, '&Private'],
]

0 comments on commit 8956837

Please sign in to comment.