-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from brave/chrome-i18n
Use chrome.i18n
- Loading branch information
Showing
8 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"appName": { | ||
"message": "The Brave Extension" | ||
}, | ||
"newTab": { | ||
"message": "New Tab" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* 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/. */ | ||
|
||
/** | ||
* Gets the locale message specified in messages.json | ||
* @param {string} The locale string | ||
*/ | ||
export const getMessage = (message) => { | ||
if (chrome.i18n) { | ||
return chrome.i18n.getMessage(message) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* global describe, it, before, after */ | ||
/* 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/. */ | ||
|
||
import sinon from 'sinon' | ||
import assert from 'assert' | ||
import * as localeAPI from '../../../../app/background/api/localeAPI' | ||
|
||
describe('locale API', () => { | ||
describe('getMessage', function () { | ||
before(function () { | ||
this.spy = sinon.spy(chrome.i18n, 'getMessage') | ||
this.message = 'NESPRESS YOURSELF' | ||
localeAPI.getMessage(this.message) | ||
}) | ||
after(function () { | ||
this.spy.restore() | ||
}) | ||
it('calls chrome.i18n.getMessage with the message', function () { | ||
assert(this.spy.calledOnce) | ||
assert.deepEqual(this.spy.getCall(0).args[0], this.message) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,10 @@ export const getMockChrome = () => { | |
}) | ||
} | ||
} | ||
}, | ||
i18n: { | ||
getMessage: function (message) { | ||
} | ||
} | ||
} | ||
} | ||
|