Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename 'incognito' to 'private' when rebasing chromium strings #1890

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 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 lib/l10nUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,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'],
]