-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update
chrome.i18n
for Manifest v3 (#39442)
* fix: update `chrome.i18n` for Manifest v3 * chore: remove i18n JSON spec (#39391)
- Loading branch information
1 parent
7698575
commit e0b1723
Showing
8 changed files
with
150 additions
and
131 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
spec/fixtures/extensions/chrome-i18n/v3/_locales/es/messages.json
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,6 @@ | ||
{ | ||
"extName": { | ||
"message": "Hola mundo!!", | ||
"description": "Nombre de extensión" | ||
} | ||
} |
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,36 @@ | ||
/* global chrome */ | ||
|
||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { | ||
sendResponse(request); | ||
}); | ||
|
||
const map = { | ||
getAcceptLanguages () { | ||
chrome.i18n.getAcceptLanguages().then((languages) => { | ||
console.log(JSON.stringify(languages)); | ||
}); | ||
}, | ||
getMessage () { | ||
const message = chrome.i18n.getMessage('extName'); | ||
console.log(JSON.stringify(message)); | ||
}, | ||
getUILanguage () { | ||
const language = chrome.i18n.getUILanguage(); | ||
console.log(JSON.stringify(language)); | ||
}, | ||
async detectLanguage (texts) { | ||
const result = []; | ||
for (const text of texts) { | ||
const language = await chrome.i18n.detectLanguage(text); | ||
result.push(language); | ||
} | ||
console.log(JSON.stringify(result)); | ||
} | ||
}; | ||
|
||
const dispatchTest = (event) => { | ||
const { method, args = [] } = JSON.parse(event.data); | ||
map[method](...args); | ||
}; | ||
|
||
window.addEventListener('message', dispatchTest, false); |
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,17 @@ | ||
{ | ||
"name": "chrome-i18n", | ||
"version": "1.0", | ||
"default_locale": "es", | ||
"content_scripts": [ | ||
{ | ||
"matches": [ | ||
"<all_urls>" | ||
], | ||
"js": [ | ||
"main.js" | ||
], | ||
"run_at": "document_start" | ||
} | ||
], | ||
"manifest_version": 3 | ||
} |