Skip to content

Commit

Permalink
chore: force copy zh lang
Browse files Browse the repository at this point in the history
  • Loading branch information
WindRunnerMax committed Dec 7, 2024
1 parent 314f031 commit 8eaadfd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"rspack"
]
}
14 changes: 7 additions & 7 deletions packages/force-copy/script/if-def/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const path = require("path");
const fs = require("fs");

// 条件编译: `process.env.PLATFORM`的深层次嵌套
// #IFDEF #ENDIF: `C/C++`预处理指令 平台层面扩展性
// 条件编译: process.env.PLATFORM 的深层次嵌套
// #IFDEF #ENDIF: C/C++ 预处理指令 平台层面扩展性

/**
* @this {import('@rspack/core').LoaderContext}
* @this {import("@rspack/core").LoaderContext}
* @param {string} source
* @returns {string}
*/
Expand Down Expand Up @@ -59,10 +59,10 @@ function IfDefineLoader(source) {
const target = lines.map((line, index) => {
// 去掉首尾的空白 去掉行首注释符号与空白符(可选)
const code = line.trim().replace(/^\/\/\s*/, "");
// 检查预处理指令起始 `#IFDEF`只会置`true`
// 检查预处理指令起始 #IFDEF 只会置 true
if (/^#IFDEF/.test(code)) {
stack.push(index);
// 如果是`true`继续即可
// 如果是 true 继续即可
if (terser) return "";
const match = code.replace("#IFDEF", "").trim();
const group = match.split("|").map(item => item.trim().toLowerCase());
Expand All @@ -73,10 +73,10 @@ function IfDefineLoader(source) {
}
return "";
}
// 检查预处理指令结束 `#IFDEF`只会置`false`
// 检查预处理指令结束 #IFDEF 只会置 false
if (/^#ENDIF$/.test(code)) {
const index = stack.pop();
// 额外的`#ENDIF`忽略
// 额外的 #ENDIF 忽略
if (index === undefined) return "";
if (index === terserIndex) {
terser = false;
Expand Down
6 changes: 2 additions & 4 deletions packages/force-copy/src/popup/components/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ import { Console } from "../console";
import { Header } from "../header";
import { Footer } from "../footer";

// https://www.rfc-editor.org/rfc/rfc9110.html#name-language-tags
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n
const i18n = new I18n(cross.i18n.getUILanguage());

export const App: FC = () => {
return (
<div className={cs(styles.container)}>
<Header i18n={i18n}></Header>

<div className={styles.hr}></div>

<Console i18n={i18n}></Console>

<div className={styles.hr}></div>

<Footer i18n={i18n}></Footer>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/force-copy/src/popup/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class I18n {
this.config = I18n.getFullConfig(language);
}

t = (key: keyof I18nTypes, defaultValue = "") => {
public t = (key: keyof I18nTypes, defaultValue = "") => {
return this.config[key] || defaultValue || key;
};

Expand Down

0 comments on commit 8eaadfd

Please sign in to comment.