File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 1+ // Bug of chrome:
2+ // chrome.i18n.getUILanguage may not work in background
13export function getUILanguage ( ) : string {
2- return chrome . i18n . getUILanguage ( )
4+ return chrome ? .i18n ? .getUILanguage ?. ( )
35}
46
5- // Bug of chrome:
7+ // Bug of chrome:
68// chrome.i18n.getMessage may not work in background
79// @see https://stackoverflow.com/questions/6089707/calling-chrome-i18n-getmessage-from-a-content-script
8- export function getMessage ( messageName : string ) : string {
9- return chrome . i18n . getMessage ( messageName )
10- }
10+ export const getMessage : ( key : string ) => string = chrome ?. i18n ?. getMessage
Original file line number Diff line number Diff line change 66 */
77
88import { getMessage } from "@api/chrome/i18n"
9- import { router , ChromeMessage } from "./message"
9+ import messages , { router , ChromeMessage } from "./message"
10+ import { IS_CHROME } from "@util/constant/environment"
11+ import { t } from ".."
1012
1113export const keyPathOf = ( key : ( root : ChromeMessage ) => string ) => key ( router )
1214
13- export const t2Chrome = ( key : ( root : ChromeMessage ) => string ) => getMessage ( keyPathOf ( key ) )
15+ export const t2Chrome = ( key : ( root : ChromeMessage ) => string ) => {
16+ if ( getMessage ) {
17+ return getMessage ( keyPathOf ( key ) )
18+ }
19+ console . error ( IS_CHROME )
20+ return t < ChromeMessage > ( messages , { key } , 'en' )
21+ }
You can’t perform that action at this time.
0 commit comments