mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-08 01:10:03 +02:00
✨ Branding locale
This commit is contained in:
parent
71ea334d1e
commit
c54e07cbd3
6 changed files with 80 additions and 9 deletions
|
@ -157,7 +157,7 @@ export async function setupProject(): Promise<void> {
|
|||
// =============================================================================
|
||||
// Filesystem templating
|
||||
|
||||
const templateDir = join(__dirname, '../..', 'template')
|
||||
export const templateDir = join(__dirname, '../..', 'template')
|
||||
|
||||
async function copyOptional(files: string[]) {
|
||||
await Promise.all(
|
||||
|
|
|
@ -2,6 +2,7 @@ import {
|
|||
copyFileSync,
|
||||
existsSync,
|
||||
mkdirSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
rmdirSync,
|
||||
rmSync,
|
||||
|
@ -11,9 +12,10 @@ import { mkdirpSync } from 'fs-extra'
|
|||
import { dirname, extname, join } from 'path'
|
||||
import sharp from 'sharp'
|
||||
import { config, log } from '..'
|
||||
import { templateDir } from '../commands'
|
||||
|
||||
import { CONFIGS_DIR, ENGINE_DIR } from '../constants'
|
||||
import { walkDirectory } from '../utils'
|
||||
import { defaultBrandsConfig, stringTemplate, walkDirectory } from '../utils'
|
||||
import { PatchBase } from './patch'
|
||||
|
||||
export const BRANDING_DIR = join(CONFIGS_DIR, 'branding')
|
||||
|
@ -66,6 +68,11 @@ export class BrandingPatch extends PatchBase {
|
|||
|
||||
this.checkForFaults()
|
||||
|
||||
const brandingConfig = {
|
||||
...(config.brands[this.name] || {}),
|
||||
...defaultBrandsConfig,
|
||||
}
|
||||
|
||||
log.debug(`Creating folder ${this.outputPath}`)
|
||||
|
||||
if (existsSync(this.outputPath))
|
||||
|
@ -100,6 +107,18 @@ export class BrandingPatch extends PatchBase {
|
|||
.resize(1024, 1024)
|
||||
.toFile(join(this.outputPath, 'content', 'about-logo@2x.png'))
|
||||
|
||||
log.debug(`Setup locales`)
|
||||
|
||||
readdirSync(join(templateDir, 'branding.optional'))
|
||||
.map((file) => [
|
||||
readFileSync(join(templateDir, 'branding.optional', file), 'utf-8'),
|
||||
join(this.outputPath, 'locales/en-US', file),
|
||||
])
|
||||
.forEach(([contents, path]) => {
|
||||
mkdirSync(dirname(path), { recursive: true })
|
||||
writeFileSync(path, stringTemplate(contents, brandingConfig))
|
||||
})
|
||||
|
||||
log.debug(`Copying files from ${BRANDING_FF}`)
|
||||
|
||||
const files = (await walkDirectory(BRANDING_FF)).filter(
|
||||
|
@ -118,7 +137,7 @@ export class BrandingPatch extends PatchBase {
|
|||
])
|
||||
.map(([contents, path]) => [
|
||||
contents.replace(CSS_REPLACE_REGEX, 'var(--theme-bg)') +
|
||||
`:root { --theme-bg: ${config.branding.backgroundColor} }`,
|
||||
`:root { --theme-bg: ${brandingConfig.backgroundColor} }`,
|
||||
path,
|
||||
])
|
||||
.forEach(([contents, path]) => {
|
||||
|
|
|
@ -67,9 +67,15 @@ export interface Config {
|
|||
generateBranding: boolean
|
||||
}
|
||||
addons: Record<string, { id: string; url: string }>
|
||||
branding: {
|
||||
backgroundColor: string
|
||||
}
|
||||
brands: Record<
|
||||
string,
|
||||
{
|
||||
backgroundColor: string
|
||||
brandShorterName: string
|
||||
brandShortName: string
|
||||
brandFullName: string
|
||||
}
|
||||
>
|
||||
}
|
||||
|
||||
const defaultConfig: Config = {
|
||||
|
@ -85,9 +91,14 @@ const defaultConfig: Config = {
|
|||
generateBranding: true,
|
||||
},
|
||||
addons: {},
|
||||
branding: {
|
||||
backgroundColor: '#2B2A33',
|
||||
},
|
||||
brands: {},
|
||||
}
|
||||
|
||||
export const defaultBrandsConfig = {
|
||||
backgroundColor: '#2B2A33',
|
||||
brandShorterName: 'Nightly',
|
||||
brandShortName: 'Nightly',
|
||||
brandFullName: 'Nightly',
|
||||
}
|
||||
|
||||
export function hasConfig(): boolean {
|
||||
|
|
7
template/branding.optional/brand.dtd
Normal file
7
template/branding.optional/brand.dtd
Normal file
|
@ -0,0 +1,7 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!ENTITY brandShorterName "${brandShorterName}">
|
||||
<!ENTITY brandShortName "${brandShortName}">
|
||||
<!ENTITY brandFullName "${brandFullName}">
|
26
template/branding.optional/brand.ftl
Normal file
26
template/branding.optional/brand.ftl
Normal file
|
@ -0,0 +1,26 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
## Firefox and Mozilla Brand
|
||||
##
|
||||
## Firefox and Mozilla must be treated as a brand.
|
||||
##
|
||||
## They cannot be:
|
||||
## - Transliterated.
|
||||
## - Translated.
|
||||
##
|
||||
## Declension should be avoided where possible, leaving the original
|
||||
## brand unaltered in prominent UI positions.
|
||||
##
|
||||
## For further details, consult:
|
||||
## https://mozilla-l10n.github.io/styleguides/mozilla_general/#brands-copyright-and-trademark
|
||||
|
||||
-brand-shorter-name = ${brandShorterName}
|
||||
-brand-short-name = ${brandShortName}
|
||||
-brand-full-name = ${brandFullName}
|
||||
# This brand name can be used in messages where the product name needs to
|
||||
# remain unchanged across different versions (Nightly, Beta, etc.).
|
||||
-brand-product-name = ${brandingGenericName}
|
||||
-vendor-short-name = ${brandingVendor}
|
||||
trademarkInfo = { " " }
|
8
template/branding.optional/brand.properties
Normal file
8
template/branding.optional/brand.properties
Normal file
|
@ -0,0 +1,8 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
brandShorterName=${brandShorterName}
|
||||
brandShortName=${brandShortName}
|
||||
brandFullName=${brandFullName}
|
||||
vendorShortName=${brandingVendor}
|
Loading…
Add table
Add a link
Reference in a new issue