Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Adds title attributes to extension buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansampson authored and bsclifton committed Apr 13, 2017
1 parent 48e66c5 commit d4cad89
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,18 +371,23 @@ module.exports.init = () => {

let insertLocaleStrings = (installInfo) => {
let pattern = /^__MSG_(.*)__$/
let properties = ['name', 'description']
let defaultLocale = installInfo.manifest.default_locale
if (defaultLocale) {
let msgPath = path.join(installInfo.base_path, '_locales', defaultLocale, 'messages.json')
if (fs.existsSync(msgPath)) {
let messages = JSON.parse(fs.readFileSync(msgPath).toString())
properties.forEach((property) => {
let matches = installInfo[property].match(pattern)
if (matches) {
installInfo[property] = messages[matches[1]].message
}
})
if (installInfo.name) {
let name = installInfo.name.match(pattern)
name && (installInfo.name = messages[name[1]].message)
}
if (installInfo.description) {
let description = installInfo.name.match(pattern)
description && (installInfo.description = messages[description[1]].message)
}
if (installInfo.manifest.browser_action.default_title) {
let defaultTitle = installInfo.manifest.browser_action.default_title.match(pattern)
defaultTitle && (installInfo.manifest.browser_action.default_title = messages[defaultTitle[1]].message)
}
}
}
return installInfo
Expand Down
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,4 @@ preventMoreAlerts=Prevent this page from creating additional dialogs
copied=Copied!
connectionError=Server connection failed. Please make sure you are connected to the Internet.
unknownError=Oops, something went wrong.
browserActionButton.title={{name}}
2 changes: 2 additions & 0 deletions app/renderer/components/browserAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class BrowserAction extends ImmutableComponent {
// TODO(bridiver) should have some visual notification of hover/press
return <div className={css(styles.browserActionButton)}>
<Button iconClass='extensionBrowserAction'
l10nId='browserActionButton'
l10nArgs={{ name: this.props.browserAction.get('title') }}
className={css(styles.extensionButton)}
inlineStyles={{
backgroundImage: extensionState.browserActionBackgroundImage(this.props.browserAction, this.props.tabId)
Expand Down
1 change: 1 addition & 0 deletions js/components/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Button extends ImmutableComponent {
data-l10n-id={this.props.l10nId}
data-test-id={this.props.testId}
data-test2-id={this.props.test2Id}
data-l10n-args={JSON.stringify(this.props.l10nArgs || {})}
style={this.props.inlineStyles}
data-button-value={this.props.dataButtonValue}
className={cx({
Expand Down

0 comments on commit d4cad89

Please sign in to comment.