Skip to content

Commit

Permalink
cleanup resources file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed Oct 4, 2018
1 parent 32cab0f commit b390ac4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 42 deletions.
34 changes: 1 addition & 33 deletions lib/l10nUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,6 @@ const braveProfileSettingsPartPath = path.resolve(path.join(srcDir, 'brave', 'ap
const chromiumVRStringsPartPath = path.resolve(path.join(srcDir, 'chrome', 'app', 'vr_strings.grdp'))
const braveVRStringsPartPath = path.resolve(path.join(srcDir, 'brave', 'app', 'vr_strings.grdp'))

// extensions_resources.grd and any of its parts files that we track localization for in transifex
// There are no XTB files for this.
const chromiumExtensionsResourcesPath = path.resolve(path.join(srcDir, 'chrome', 'browser', 'resources', 'md_extensions', 'extensions_resources.grd'))
const braveExtensionsResourcesPath = path.resolve(path.join(srcDir, 'brave', 'browser', 'resources', 'md_extensions', 'extensions_resources.grd'))

// settings_resources.grd and any of its parts files that we track localization for in transifex
// There are no XTB files for this.
const chromiumSettingsResourcesPath = path.resolve(path.join(srcDir, 'chrome', 'browser', 'resources', 'settings', 'settings_resources.grd'))
const braveSettingsResourcesPath = path.resolve(path.join(srcDir, 'brave', 'browser', 'resources', 'settings', 'settings_resources.grd'))

// browser_resources.grd and any of its parts files that we track localization for in transifex
// We currently do not need to track media_router_resources.grdp
// There are no XTB files for this.
const chromiumBrowserResourcesPath = path.resolve(path.join(srcDir, 'chrome', 'browser', 'browser_resources.grd'))
const braveBrowserResourcesPath = path.resolve(path.join(srcDir, 'brave', 'browser', 'browser_resources.grd'))

// The following are not generated files but still need to be tracked so they get sent to transifex
// These xtb files don't need to be copied anywhere.
// brave_generated_resources.grd maps to brave/app/resources/brave_generated_resources*.xtb,
// brave_component_resources.grd maps to brave/components/resources/strings/brave_components_resources*.xtb
// messages.json localization is handled inside of brave-extension.
const braveSpecificGeneratedResourcesPath = path.resolve(path.join(srcDir, 'brave', 'app', 'brave_generated_resources.grd'))
const braveComponentsResourcesPath = path.resolve(path.join(srcDir, 'brave', 'components', 'resources', 'brave_components_resources.grd'))
const braveExtensionMessagesPath = path.resolve(path.join(srcDir, 'brave', 'vendor', 'brave-extension', 'app', '_locales', 'en_US', 'messages.json'))

// When adding new grd or grd files, never add a grdp part path without a parent grd path.
// Group them with a leading and trailing newline to keep this file organized.

Expand All @@ -89,25 +64,18 @@ const chromiumToAutoGeneratedBraveMapping = {
[chromiumPrintingStringsPartPath]: bravePrintingStringsPartPath,
[chromiumProfileSettingsPartPath]: braveProfileSettingsPartPath,
[chromiumVRStringsPartPath]: braveVRStringsPartPath,
[chromiumExtensionsResourcesPath]: braveExtensionsResourcesPath,
[chromiumSettingsResourcesPath]: braveSettingsResourcesPath,
[chromiumBrowserResourcesPath]: braveBrowserResourcesPath
}

// Same as with chromiumToAutoGeneratedBraveMapping but maps in the opposite direction
module.exports.autoGeneratedBraveToChromiumMapping = Object.keys(chromiumToAutoGeneratedBraveMapping)
.reduce((obj, key) => ({ ...obj, [chromiumToAutoGeneratedBraveMapping[key]]: key }), {})

// All paths which are not generated
module.exports.braveNonGeneratedPaths = [
//braveSpecificGeneratedResourcesPath, braveComponentsResourcesPath, braveExtensionMessagesPath
]
// All paths which are generated
module.exports.braveAutoGeneratedPaths = Object.values(chromiumToAutoGeneratedBraveMapping)

// Brave specific strings and Chromium mapped Brave strings will be here.
// But you only need to add the Brave specific strings manually here.
module.exports.allBravePaths = module.exports.braveNonGeneratedPaths.concat(module.exports.braveAutoGeneratedPaths)
module.exports.allBravePaths = module.exports.braveAutoGeneratedPaths

// Get all GRD and JSON paths whether they are generatd or not
// Push and pull scripts for l10n use this.
Expand Down
9 changes: 0 additions & 9 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ const util = {
const braveComponentsDir = path.join(config.projects['brave-core'].dir, 'components')
const chromeAppDir = path.join(config.srcDir, 'chrome', 'app')
const braveAppDir = path.join(config.projects['brave-core'].dir, 'app')
const chromeResourcesDir = path.join(config.srcDir, 'chrome', 'browser', 'resources')
const braveResourcesDir = path.join(config.projects['brave-core'].dir, 'browser', 'resources')
const chromeBrowserDir = path.join(config.srcDir, 'chrome', 'browser')
const braveBrowserDir = path.join(config.projects['brave-core'].dir, 'browser')
const braveAppVectorIconsDir = path.join(config.projects['brave-core'].dir, 'vector_icons', 'chrome', 'app')

let fileMap = new Set();
Expand All @@ -110,11 +106,6 @@ const util = {
fileMap.add([path.join(braveComponentsDir, 'resources', 'default_100_percent', 'brave'), path.join(chromeComponentsDir, 'resources', 'default_100_percent', 'chromium')])
fileMap.add([path.join(braveComponentsDir, 'resources', 'default_200_percent', 'brave'), path.join(chromeComponentsDir, 'resources', 'default_200_percent', 'chromium')])
fileMap.add([path.join(braveAppVectorIconsDir, 'vector_icons', 'brave'), path.join(chromeAppDir, 'vector_icons', 'brave')])
// Add brave specific pages.
fileMap.add([path.join(braveResourcesDir, 'settings', 'brave_page_visibility.js'), path.join(chromeResourcesDir, 'settings', 'brave_page_visibility.js')])
fileMap.add([path.join(braveResourcesDir, 'settings', 'brave_appearance_page'), path.join(chromeResourcesDir, 'settings', 'brave_appearance_page')])
fileMap.add([path.join(braveResourcesDir, 'settings', 'brave_privacy_page'), path.join(chromeResourcesDir, 'settings', 'brave_privacy_page')])
fileMap.add([path.join(braveResourcesDir, 'settings', 'default_brave_shields_page'), path.join(chromeResourcesDir, 'settings', 'default_brave_shields_page')])

for (const [source, output] of fileMap) {
let sourceFiles = []
Expand Down

0 comments on commit b390ac4

Please sign in to comment.