File tree Expand file tree Collapse file tree 5 files changed +43
-29
lines changed
Expand file tree Collapse file tree 5 files changed +43
-29
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,13 @@ const __MANIFEST__: Manifest = {
99 description : "Force Copy Everything" ,
1010 default_locale : "en" ,
1111 icons : {
12- 32 : "./ static/favicon.128.png" ,
13- 96 : "./ static/favicon.128.png" ,
14- 128 : "./ static/favicon.128.png" ,
12+ 32 : "static/favicon.128.png" ,
13+ 96 : "static/favicon.128.png" ,
14+ 128 : "static/favicon.128.png" ,
1515 } ,
1616 action : {
1717 default_popup : "popup.html" ,
18- default_icon : "./ static/favicon.128.png" ,
18+ default_icon : "static/favicon.128.png" ,
1919 } ,
2020 content_scripts : [
2121 {
Original file line number Diff line number Diff line change @@ -13,7 +13,9 @@ import { Tools } from "../tools";
1313
1414export const Footer : FC < {
1515 i18n : I18n ;
16- } > = ( { i18n } ) => {
16+ } > = props => {
17+ const { i18n } = props ;
18+
1719 return (
1820 < div className = { styles . footer } >
1921 < Trigger trigger = "click" popup = { ( ) => < Tools i18n = { i18n } > </ Tools > } >
Original file line number Diff line number Diff line change @@ -5,7 +5,9 @@ import type { I18n } from "@/popup/i18n";
55
66export const Header : FC < {
77 i18n : I18n ;
8- } > = ( { i18n } ) => {
8+ } > = props => {
9+ const { i18n } = props ;
10+
911 return (
1012 < div className = { cs ( styles . captain ) } >
1113 < img src = "./static/favicon.128.png" alt = "" />
Original file line number Diff line number Diff line change @@ -8,61 +8,62 @@ const GridItem = Grid.GridItem;
88
99export const Tools : FC < {
1010 i18n : I18n ;
11- visible ?: boolean ;
12- } > = ( { i18n } ) => {
11+ } > = props => {
12+ const { i18n } = props ;
13+
1314 return (
1415 < div className = { styles . container } >
1516 < Grid cols = { 2 } colGap = { 10 } rowGap = { 5 } >
1617 < GridItem >
1718 < Button
1819 size = "mini"
19- onClick = { ( ) =>
20+ onClick = { ( ) => {
2021 PCBridge . postToContent ( {
2122 type : PCBridge . REQUEST . DEBUG_MOUSE_EVENT ,
2223 payload : null ,
23- } )
24- }
24+ } ) ;
25+ } }
2526 >
2627 { i18n . t ( "Tools.MouseEvent" ) }
2728 </ Button >
2829 </ GridItem >
2930 < GridItem >
3031 < Button
31- onClick = { ( ) =>
32+ onClick = { ( ) => {
3233 PCBridge . postToContent ( {
3334 type : PCBridge . REQUEST . DEBUG_FOCUS_EVENT ,
3435 payload : null ,
35- } )
36- }
36+ } ) ;
37+ } }
3738 size = "mini"
3839 >
3940 { i18n . t ( "Tools.FocusEvent" ) }
4041 </ Button >
4142 </ GridItem >
4243 < GridItem >
4344 < Button
44- onClick = { ( ) =>
45+ onClick = { ( ) => {
4546 PCBridge . postToContent ( {
46- type : PCBridge . REQUEST . DEBUG_EDITABLE ,
47+ type : PCBridge . REQUEST . DEBUG_PASTE_EVENT ,
4748 payload : null ,
48- } )
49- }
49+ } ) ;
50+ } }
5051 size = "mini"
5152 >
52- { i18n . t ( "Tools.Editable " ) }
53+ { i18n . t ( "Tools.PasteEvent " ) }
5354 </ Button >
5455 </ GridItem >
5556 < GridItem >
5657 < Button
57- onClick = { ( ) =>
58+ onClick = { ( ) => {
5859 PCBridge . postToContent ( {
59- type : PCBridge . REQUEST . DEBUG_PASTE_EVENT ,
60+ type : PCBridge . REQUEST . DEBUG_EDITABLE ,
6061 payload : null ,
61- } )
62- }
62+ } ) ;
63+ } }
6364 size = "mini"
6465 >
65- { i18n . t ( "Tools.PasteEvent " ) }
66+ { i18n . t ( "Tools.Editable " ) }
6667 </ Button >
6768 </ GridItem >
6869 </ Grid >
Original file line number Diff line number Diff line change @@ -7,23 +7,32 @@ const cache: Record<string, I18nTypes> = {};
77
88export class I18n {
99 private config : I18nTypes ;
10+ private language : string ;
1011 constructor ( language : string ) {
11- this . config = I18n . getFullConfig ( language ) ;
12+ this . language = language . toLowerCase ( ) ;
13+ this . config = I18n . getFullConfig ( this . language ) ;
1214 }
1315
1416 public t = ( key : keyof I18nTypes , defaultValue = "" ) => {
1517 return this . config [ key ] || defaultValue || key ;
1618 } ;
1719
18- private static getFullConfig = ( key : string ) => {
19- if ( cache [ key ] ) return cache [ key ] ;
20+ public get p ( ) : typeof en {
21+ if ( this . language . startsWith ( "zh" ) ) {
22+ return zh ;
23+ }
24+ return en ;
25+ }
26+
27+ private static getFullConfig = ( lang : string ) => {
28+ if ( cache [ lang ] ) return cache [ lang ] ;
2029 let config ;
21- if ( key . toLowerCase ( ) . startsWith ( "zh" ) ) {
30+ if ( lang . startsWith ( "zh" ) ) {
2231 config = this . generateFlattenConfig ( zh ) ;
2332 } else {
2433 config = this . generateFlattenConfig ( en ) ;
2534 }
26- cache [ key ] = config ;
35+ cache [ lang ] = config ;
2736 return config ;
2837 } ;
2938
You can’t perform that action at this time.
0 commit comments