refactor: ♻️ 重构汉化

This commit is contained in:
lainbo
2026-02-10 14:18:45 +08:00
parent f01955a390
commit 07e969303c
442 changed files with 1229 additions and 965 deletions

1
.eslintcache Normal file

File diff suppressed because one or more lines are too long

74
.husky/pre-commit Normal file
View File

@@ -0,0 +1,74 @@
#!/bin/sh
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
set -x
fi
if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi
call_lefthook()
{
if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook.exe -h >/dev/null 2>&1
then
lefthook.exe "$@"
elif lefthook.bat -h >/dev/null 2>&1
then
lefthook.bat "$@"
elif D:\Repositories\Self\component-party\node_modules\.pnpm\lefthook-windows-x64@2.0.13\node_modules\lefthook-windows-x64\bin\lefthook.exe -h >/dev/null 2>&1
then
D:\Repositories\Self\component-party\node_modules\.pnpm\lefthook-windows-x64@2.0.13\node_modules\lefthook-windows-x64\bin\lefthook.exe "$@"
else
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe"
then
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe" "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"
elif go tool lefthook -h >/dev/null 2>&1
then
go tool lefthook "$@"
elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package lefthook >/dev/null 2>&1
then
swift package --build-path .build/lefthook --disable-sandbox lefthook "$@"
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
elif uv run lefthook -h >/dev/null 2>&1
then
uv run lefthook "$@"
elif mise exec -- lefthook -h >/dev/null 2>&1
then
mise exec -- lefthook "$@"
elif devbox run lefthook -h >/dev/null 2>&1
then
devbox run lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
fi
}
call_lefthook run "pre-commit" "$@"

74
.husky/prepare-commit-msg Normal file
View File

@@ -0,0 +1,74 @@
#!/bin/sh
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
set -x
fi
if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi
call_lefthook()
{
if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook.exe -h >/dev/null 2>&1
then
lefthook.exe "$@"
elif lefthook.bat -h >/dev/null 2>&1
then
lefthook.bat "$@"
elif D:\Repositories\Self\component-party\node_modules\.pnpm\lefthook-windows-x64@2.0.13\node_modules\lefthook-windows-x64\bin\lefthook.exe -h >/dev/null 2>&1
then
D:\Repositories\Self\component-party\node_modules\.pnpm\lefthook-windows-x64@2.0.13\node_modules\lefthook-windows-x64\bin\lefthook.exe "$@"
else
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe"
then
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe" "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"
elif go tool lefthook -h >/dev/null 2>&1
then
go tool lefthook "$@"
elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package lefthook >/dev/null 2>&1
then
swift package --build-path .build/lefthook --disable-sandbox lefthook "$@"
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
elif uv run lefthook -h >/dev/null 2>&1
then
uv run lefthook "$@"
elif mise exec -- lefthook -h >/dev/null 2>&1
then
mise exec -- lefthook "$@"
elif devbox run lefthook -h >/dev/null 2>&1
then
devbox run lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
fi
}
call_lefthook run "prepare-commit-msg" "$@"

95
CLAUDE.md Normal file
View File

@@ -0,0 +1,95 @@
# Component Party 中文版 - 项目维护指南
## 项目概述
本项目是 [component-party.dev](https://github.com/matschik/component-party.dev) 的中文汉化 fork用于对比不同 JavaScript 框架的语法差异,面向中文母语开发者。
## 分支策略
- **main**: 与上游 `matschik/component-party.dev` 的 main 分支保持完全同步,不做任何修改
- **deploy**: 基于 main 的汉化分支,包含所有中文翻译,用于部署
- **upstream**: 远程仓库,指向 `https://github.com/matschik/component-party.dev.git`
## 同步上游与汉化工作流
```bash
# 1. 同步上游到 main
git fetch upstream
git checkout main
git merge upstream/main --ff-only
git push origin main
# 2. 将 main 合并到 deploy
git checkout deploy
git merge main
# 解决冲突(通常是代码内容冲突,不会有 rename 冲突)
# 汉化新增内容
git push origin deploy
```
## 汉化架构(重要)
汉化分为两层,设计目标是最小化与上游的合并冲突:
### 第一层:标题翻译(零冲突)
- 翻译映射文件: `i18n/zh-CN.json`
- 构建脚本修改: `build/lib/generateContent.ts` 中的 `dirNameToTitle()` 函数
- **不修改 content 目录名**,通过映射表将英文标题转换为中文
- 上游新增的 section/snippet 会自动显示英文原文,只需在 JSON 中补充翻译即可
### 第二层:代码内容汉化(可控冲突)
- 直接修改 `content/` 目录下各框架代码文件中的**字符串字面量**
- **不改文件名和路径**,只改文件内容
- 翻译规则参考 `i18n/zh-CN.json` 中的约定
### UI 文案汉化
- `src/components/Header.svelte` - 站点标题
- `src/Index.svelte` - 页面文案、SEO meta、空状态提示等
## 常用翻译对照表
| 英文 | 中文 |
| ------------------------- | -------------- |
| John | 张三 |
| Jane | 李四 |
| Hello {name} | 你好 {name} |
| Hello world | 你好,世界 |
| red/green/blue | 红/绿/蓝 |
| red/orange/green (交通灯) | 红灯/黄灯/绿灯 |
| Counter: | 计数器: |
| Page title: | 页面标题: |
| Current time: | 当前时间: |
| Are you happy? | 你快乐吗? |
| YES / NO | 是的!/ 不是! |
| Click me! | 点我! |
| unicorn42 | abcdefg |
完整对照见 `i18n/zh-CN.json`
## 技术栈
- 包管理器: pnpm
- 框架: Svelte 5 + Vite
- 构建: `content/` 目录由 Vite 插件在 `buildStart` 时扫描生成到 `src/generatedContent/`
- `src/generatedContent/` 是自动生成的,不要手动编辑,不需要提交
## 关键文件
| 文件 | 说明 |
| ------------------------------------ | ------------------------------------------ |
| `i18n/zh-CN.json` | 标题翻译映射 + UI 文案翻译 |
| `build/lib/generateContent.ts` | 内容生成脚本(已添加翻译查表逻辑) |
| `build/generateContentVitePlugin.ts` | Vite 插件,负责触发内容生成 |
| `content/` | 各框架代码示例(汉化在此目录的文件内容中) |
| `frameworks.ts` | 框架定义列表 |
| `src/Index.svelte` | 主页面组件 |
| `src/components/Header.svelte` | 头部组件 |
## 注意事项
- content 目录下的文件**只改内容不改路径**,这是避免合并地狱的核心原则
- 翻译只针对用户可见的字符串字面量不翻译变量名、API 名、组件名
- 上游可能会新增框架目录(如 emberPolaris、svelte5合并后需要检查新文件是否需要汉化

View File

@@ -240,44 +240,6 @@ How do we solve this ? Developers love having framework overview by examples. It
</details>
<details>
<summary>
<img width="18" height="18" src="public/framework/ember.svg" />
<b>Ember Octane</b>
<img src="https://us-central1-progress-markdown.cloudfunctions.net/progress/96" />
</summary>
- [x] Reactivity
- [x] Declare state
- [x] Update state
- [x] Computed state
- [x] Templating
- [x] Minimal template
- [x] Styling
- [x] Loop
- [x] Event click
- [x] Dom ref
- [x] Conditional
- [x] Lifecycle
- [x] On mount
- [x] On unmount
- [x] Component composition
- [x] Props
- [x] Emit to parent
- [x] Slot
- [x] Slot fallback
- [x] Context
- [x] Form input
- [x] Input text
- [x] Checkbox
- [x] Radio
- [x] Select
- [ ] Webapp features
- [ ] Render app
- [x] Fetch data
</details>
<details>
<summary>
<img width="18" height="18" src="public/framework/ember.svg" />
@@ -316,6 +278,44 @@ How do we solve this ? Developers love having framework overview by examples. It
</details>
<details>
<summary>
<img width="18" height="18" src="public/framework/ember.svg" />
<b>Ember Octane</b>
<img src="https://us-central1-progress-markdown.cloudfunctions.net/progress/96" />
</summary>
- [x] Reactivity
- [x] Declare state
- [x] Update state
- [x] Computed state
- [x] Templating
- [x] Minimal template
- [x] Styling
- [x] Loop
- [x] Event click
- [x] Dom ref
- [x] Conditional
- [x] Lifecycle
- [x] On mount
- [x] On unmount
- [x] Component composition
- [x] Props
- [x] Emit to parent
- [x] Slot
- [x] Slot fallback
- [x] Context
- [x] Form input
- [x] Input text
- [x] Checkbox
- [x] Radio
- [x] Select
- [ ] Webapp features
- [ ] Render app
- [x] Fetch data
</details>
<details>
<summary>
<img width="18" height="18" src="public/framework/solid.svg" />

View File

@@ -13,6 +13,7 @@ import {
markdownToHighlightedHtml,
} from "./highlighter.ts";
import kebabCase from "just-kebab-case";
import i18n from "../../i18n/zh-CN.json" with { type: "json" };
interface File {
fileName: string;
@@ -349,7 +350,12 @@ export default async function generateContent(
}
function dirNameToTitle(dirName: string): string {
return capitalize(dirName.split("-").splice(1).join(" "));
const title = capitalize(dirName.split("-").splice(1).join(" "));
const sectionTranslation = (i18n.sections as Record<string, string>)[title];
if (sectionTranslation) return sectionTranslation;
const snippetTranslation = (i18n.snippets as Record<string, string>)[title];
if (snippetTranslation) return snippetTranslation;
return title;
}
function capitalize(string: string): string {

View File

@@ -1 +1 @@
<h1 x-data="{ name: 'John' }" x-text="name"></h1>
<h1 x-data="{ name: '张三' }" x-text="name"></h1>

View File

@@ -2,10 +2,10 @@ import { Component, NgModule } from "@angular/core";
@Component({
selector: "app-name",
template: `<h1>Hello {{ name }}</h1>`,
template: `<h1>你好 {{ name }}</h1>`,
})
export class NameComponent {
name = "John";
name = "张三";
}
@NgModule({

View File

@@ -2,8 +2,8 @@ import { Component, signal } from "@angular/core";
@Component({
selector: "app-name",
template: `<h1>Hello {{ name() }}</h1>`,
template: `<h1>你好 {{ name() }}</h1>`,
})
export class NameComponent {
name = signal("John");
name = signal("张三");
}

View File

@@ -1,3 +1,3 @@
<template>
<h1>Hello ${name}</h1>
<h1>你好 ${name}</h1>
</template>

View File

@@ -1,3 +1,3 @@
export class Name {
name = "John";
name = "张三";
}

View File

@@ -1 +1 @@
<h1>Hello ${name}</h1>
<h1>你好 ${name}</h1>

View File

@@ -1,3 +1,3 @@
export class Name {
name = "John";
name = "张三";
}

View File

@@ -1 +1 @@
<h1>Hello {{this.name}}</h1>
<h1>你好 {{this.name}}</h1>

View File

@@ -1,5 +1,5 @@
import Component from "@glimmer/component";
export default class NameComponent extends Component {
name = "John";
name = "张三";
}

View File

@@ -1,9 +1,9 @@
import Component from "@glimmer/component";
export default class NameComponent extends Component {
name = "John";
name = "张三";
<template>
<h1>Hello {{this.name}}</h1>
<h1>你好 {{this.name}}</h1>
</template>
}

View File

@@ -4,9 +4,9 @@ import { customElement, state } from "lit/decorators.js";
@customElement("x-name")
export class XName extends LitElement {
@state()
name = "John";
name = "张三";
render() {
return html`<h1>Hello ${this.name}!</h1>`;
return html`<h1>你好 ${this.name}!</h1>`;
}
}

View File

@@ -1,2 +1,2 @@
<let/name="John">
<h1>Hello ${name}</h1>
<let/name="张三">
<h1>你好 ${name}</h1>

View File

@@ -1,9 +1,9 @@
import m from "mithril";
export default function Name() {
let name = "John";
let name = "张三";
return {
view: () => m("h1", `Hello ${name}`),
view: () => m("h1", `你好 ${name}`),
};
}

View File

@@ -1,7 +1,7 @@
import { component$, useSignal } from "@builder.io/qwik";
export const Name = component$(() => {
const name = useSignal("John");
const name = useSignal("张三");
return <h1>Hello {name.value}</h1>;
return <h1> {name.value}</h1>;
});

View File

@@ -1,7 +1,7 @@
import { useState } from "react";
export default function Name() {
const [name] = useState("John");
const [name] = useState("张三");
return <h1>Hello {name}</h1>;
return <h1>你好 {name}</h1>;
}

View File

@@ -1,7 +1,7 @@
import { track } from "ripple";
export component Name() {
let name = track("John");
let name = track("张三");
<h1>{`Hello ${@name}`}</h1>
<h1>{`你好 ${@name}`}</h1>
}

View File

@@ -1,7 +1,7 @@
import { createSignal } from "solid-js";
export default function Name() {
const [name] = createSignal("John");
const [name] = createSignal("张三");
return <h1>Hello {name()}</h1>;
return <h1>你好 {name()}</h1>;
}

View File

@@ -1,5 +1,5 @@
<script>
let name = "John";
let name = "张三";
</script>
<h1>Hello {name}</h1>
<h1>你好 {name}</h1>

View File

@@ -1,5 +1,5 @@
<script>
let name = $state("John");
let name = $state("张三");
</script>
<h1>Hello {name}</h1>
<h1>你好 {name}</h1>

View File

@@ -2,12 +2,12 @@
export default {
data() {
return {
name: "John",
name: "张三",
};
},
};
</script>
<template>
<h1>Hello {{ name }}</h1>
<h1>你好 {{ name }}</h1>
</template>

View File

@@ -1,8 +1,8 @@
<script setup>
import { ref } from "vue";
const name = ref("John");
const name = ref("张三");
</script>
<template>
<h1>Hello {{ name }}</h1>
<h1>你好 {{ name }}</h1>
</template>

View File

@@ -1 +1 @@
<h1 x-data="{ name: 'John' }" x-init="name = 'Jane'" x-text="name"></h1>
<h1 x-data="{ name: '张三' }" x-init="name = '李四'" x-text="name"></h1>

View File

@@ -2,13 +2,13 @@ import { Component, NgModule } from "@angular/core";
@Component({
selector: "app-name",
template: `<h1>Hello {{ name }}</h1>`,
template: `<h1>你好 {{ name }}</h1>`,
})
export class NameComponent {
name = "John";
name = "张三";
constructor() {
this.name = "Jane";
this.name = "李四";
}
}

View File

@@ -2,12 +2,12 @@ import { Component, signal } from "@angular/core";
@Component({
selector: "app-name",
template: `<h1>Hello {{ name() }}</h1>`,
template: `<h1>你好 {{ name() }}</h1>`,
})
export class NameComponent {
name = signal("John");
name = signal("张三");
constructor() {
this.name.set("Jane");
this.name.set("李四");
}
}

View File

@@ -1,3 +1,3 @@
<template>
<h1>Hello ${name}</h1>
<h1>你好 ${name}</h1>
</template>

View File

@@ -1,7 +1,7 @@
export class Name {
name = "John";
name = "张三";
constructor() {
this.name = "Jane";
this.name = "李四";
}
}

View File

@@ -1 +1 @@
<h1>Hello ${name}</h1>
<h1>你好 ${name}</h1>

View File

@@ -1,7 +1,7 @@
export class Name {
name = "John";
name = "张三";
constructor() {
this.name = "Jane";
this.name = "李四";
}
}

View File

@@ -1 +1 @@
<h1>Hello {{this.name}}</h1>
<h1>你好 {{this.name}}</h1>

View File

@@ -2,11 +2,11 @@ import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
export default class NameComponent extends Component {
@tracked name = "John";
@tracked name = "张三";
constructor(owner, args) {
super(owner, args);
this.name = "Jane";
this.name = "李四";
}
}

View File

@@ -2,15 +2,15 @@ import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
export default class CounterComponent extends Component {
@tracked name = "John";
@tracked name = "张三";
constructor(owner, args) {
super(owner, args);
this.name = "Jane";
this.name = "李四";
}
<template>
<h1>Hello {{this.name}}</h1>
<h1>你好 {{this.name}}</h1>
</template>
}

View File

@@ -4,14 +4,14 @@ import { customElement, state } from "lit/decorators.js";
@customElement("x-name")
export class XName extends LitElement {
@state()
name = "John";
name = "张三";
constructor() {
super();
this.name = "Jane";
this.name = "李四";
}
render() {
return html`<h1>Hello ${this.name}!</h1>`;
return html`<h1>你好 ${this.name}!</h1>`;
}
}

View File

@@ -1,3 +1,3 @@
<let/name="John">
<script>name = "Jane"</script>
<h1>Hello ${name}</h1>
<let/name="张三">
<script>name = "李四"</script>
<h1>你好 ${name}</h1>

View File

@@ -1,9 +1,9 @@
import m from "mithril";
export default function Name() {
let name = "John";
name = "Jane";
let name = "张三";
name = "李四";
return {
view: () => m("h1", `Hello ${name}`),
view: () => m("h1", `你好 ${name}`),
};
}

View File

@@ -1,11 +1,11 @@
import { component$, useTask$, useSignal } from "@builder.io/qwik";
export const Name = component$(() => {
const name = useSignal("John");
const name = useSignal("张三");
useTask$(() => {
name.value = "Jane";
name.value = "李四";
});
return <h1>Hello {name.value}</h1>;
return <h1> {name.value}</h1>;
});

View File

@@ -1,11 +1,11 @@
import { useEffect, useState } from "react";
export default function Name() {
const [name, setName] = useState("John");
const [name, setName] = useState("张三");
useEffect(() => {
setName("Jane");
setName("李四");
}, []);
return <h1>Hello {name}</h1>;
return <h1>你好 {name}</h1>;
}

View File

@@ -1,8 +1,8 @@
import { track } from "ripple";
export component Name() {
let name = track("John");
@name = "Jane";
let name = track("张三");
@name = "李四";
<h1>{`Hello ${@name}`}</h1>
<h1>{`你好 ${@name}`}</h1>
}

View File

@@ -1,8 +1,8 @@
import { createSignal } from "solid-js";
export default function Name() {
const [name, setName] = createSignal("John");
setName("Jane");
const [name, setName] = createSignal("张三");
setName("李四");
return <h1>Hello {name()}</h1>;
return <h1>你好 {name()}</h1>;
}

View File

@@ -1,6 +1,6 @@
<script>
let name = "John";
name = "Jane";
let name = "张三";
name = "李四";
</script>
<h1>Hello {name}</h1>
<h1>你好 {name}</h1>

View File

@@ -1,6 +1,6 @@
<script>
let name = $state("John");
name = "Jane";
let name = $state("张三");
name = "李四";
</script>
<h1>Hello {name}</h1>
<h1>你好 {name}</h1>

View File

@@ -2,15 +2,15 @@
export default {
data() {
return {
name: "John",
name: "张三",
};
},
created() {
this.name = "Jane";
this.name = "李四";
},
};
</script>
<template>
<h1>Hello {{ name }}</h1>
<h1>你好 {{ name }}</h1>
</template>

View File

@@ -1,9 +1,9 @@
<script setup>
import { ref } from "vue";
const name = ref("John");
name.value = "Jane";
const name = ref("张三");
name.value = "李四";
</script>
<template>
<h1>Hello {{ name }}</h1>
<h1>你好 {{ name }}</h1>
</template>

View File

@@ -1 +1 @@
<h1>Hello world</h1>
<h1>你好,世界</h1>

View File

@@ -2,7 +2,7 @@ import { Component, NgModule } from "@angular/core";
@Component({
selector: "app-helloworld",
template: `<h1>Hello world</h1>`,
template: `<h1>你好,世界</h1>`,
})
export class HelloworldComponent {}

View File

@@ -2,6 +2,6 @@ import { Component } from "@angular/core";
@Component({
selector: "app-hello-world",
template: `<h1>Hello world</h1>`,
template: `<h1>你好,世界</h1>`,
})
export class HelloWorldComponent {}

View File

@@ -1,3 +1,3 @@
<template>
<h1>Hello world</h1>
<h1>你好,世界</h1>
</template>

View File

@@ -1 +1 @@
<h1>Hello world</h1>
<h1>你好,世界</h1>

View File

@@ -1 +1 @@
<h1>Hello world</h1>
<h1>你好,世界</h1>

View File

@@ -1,3 +1,3 @@
<template>
<h1>Hello world</h1>
<h1>你好,世界</h1>
</template>

View File

@@ -4,6 +4,6 @@ import { customElement } from "lit/decorators.js";
@customElement("hello-world")
export class HelloWorld extends LitElement {
render() {
return html`<h1>Hello world</h1>`;
return html`<h1>你好,世界</h1>`;
}
}

View File

@@ -1 +1 @@
<h1>Hello world</h1>
<h1>你好,世界</h1>

View File

@@ -2,6 +2,6 @@ import m from "mithril";
export default function HelloWorld() {
return {
view: () => m("h1", "Hello World"),
view: () => m("h1", "你好,世界"),
};
}

View File

@@ -1,3 +1,3 @@
export const HelloWorld = () => {
return <div>Hello World</div>;
return <div></div>;
};

View File

@@ -1,3 +1,3 @@
export default function HelloWorld() {
return <h1>Hello world</h1>;
return <h1>你好世界</h1>;
}

View File

@@ -1,3 +1,3 @@
export component HelloWorld() {
<h1>{"Hello world"}</h1>
<h1>{"你好,世界"}</h1>
}

View File

@@ -1,3 +1,3 @@
export default function HelloWorld() {
return <h1>Hello World!</h1>;
return <h1>你好世界</h1>;
}

View File

@@ -1 +1 @@
<h1>Hello world</h1>
<h1>你好,世界</h1>

View File

@@ -1 +1 @@
<h1>Hello world</h1>
<h1>你好,世界</h1>

View File

@@ -1,3 +1,3 @@
<template>
<h1>Hello world</h1>
<h1>你好世界</h1>
</template>

View File

@@ -1,3 +1,3 @@
<template>
<h1>Hello world</h1>
<h1>你好世界</h1>
</template>

View File

@@ -1,5 +1,5 @@
<h1 class="title">I am red</h1>
<button style="font-size: 10rem">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem">我是一个按钮</button>
<style>
.title {

View File

@@ -3,8 +3,8 @@ import { Component, NgModule } from "@angular/core";
@Component({
selector: "app-cssstyle",
template: `
<h1 class="title">I am red</h1>
<button style="font-size: 10rem">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem">我是一个按钮</button>
`,
styles: [
`

View File

@@ -3,8 +3,8 @@ import { Component } from "@angular/core";
@Component({
selector: "app-css-style",
template: `
<h1 class="title">I am red</h1>
<button style="font-size: 10rem">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem">我是一个按钮</button>
`,
styles: `
.title {

View File

@@ -1,6 +1,6 @@
<template>
<require from="./styling.css"></require>
<h1 class="title">I am red</h1>
<button style="font-size: 10rem">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem">我是一个按钮</button>
</template>

View File

@@ -1,2 +1,2 @@
<h1 class="title">I am red</h1>
<button style="font-size: 10rem">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem">我是一个按钮</button>

View File

@@ -1,2 +1,2 @@
<h1 class="title">I am red</h1>
<button style="font-size: 10rem;">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem;">我是一个按钮</button>

View File

@@ -1,6 +1,6 @@
<template>
<h1 class="title">I am red</h1>
<button style="font-size: 10rem;">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem;">我是一个按钮</button>
<style>
.title {

View File

@@ -12,8 +12,8 @@ export class CssStyle extends LitElement {
render() {
return html`
<h1 class="title">I am red</h1>
<button style=${styleMap({ fontSize: "10rem" })}>I am a button</button>
<h1 class="title">我是红色的</h1>
<button style=${styleMap({ fontSize: "10rem" })}>我是一个按钮</button>
`;
}
}

View File

@@ -1,6 +1,6 @@
<h1.title>I am red</h1>
<button style={ "font-size": "10rem" }>I am a button</button>
<button class=scopedButton>I am a style-scoped button</button>
<h1.title>我是红色的</h1>
<button style={ "font-size": "10rem" }>我是一个按钮</button>
<button class=scopedButton>我是一个样式作用域按钮</button>
<style>
.title {

View File

@@ -6,8 +6,8 @@ export default function CssStyle() {
view: () =>
m(
"div",
m("h1.title", "I am red"),
m("button", { style: { fontSize: "10rem" } }, "I am a button"),
m("h1.title", "我是红色的"),
m("button", { style: { fontSize: "10rem" } }, "我是一个按钮"),
),
};
}

View File

@@ -9,8 +9,8 @@ export const App = component$(() => {
return (
<>
<h1 class="title">I am red</h1>
<button style={{ "font-size": "10rem" }}>I am a button</button>
<h1 class="title"></h1>
<button style={{ "font-size": "10rem" }}></button>
</>
);
});

View File

@@ -3,8 +3,8 @@ import "./style.css";
export default function CssStyle() {
return (
<>
<h1 className="title">I am red</h1>
<button style={{ fontSize: "10rem" }}>I am a button</button>
<h1 className="title">我是红色的</h1>
<button style={{ fontSize: "10rem" }}>我是一个按钮</button>
</>
);
}

View File

@@ -1,6 +1,6 @@
export component CssStyle() {
<h1 class="title">{"I am red"}</h1>
<button style="font-size: 10rem;">{"I am a button"}</button>
<h1 class="title">{"我是红色的"}</h1>
<button style="font-size: 10rem;">{"我是一个按钮"}</button>
<style>
.title {

View File

@@ -3,8 +3,8 @@ import "./style.css";
export default function CssStyle() {
return (
<>
<h1 class="title">I am red</h1>
<button style={{ "font-size": "10rem" }}>I am a button</button>
<h1 class="title">我是红色的</h1>
<button style={{ "font-size": "10rem" }}>我是一个按钮</button>
</>
);
}

View File

@@ -1,5 +1,5 @@
<h1 class="title">I am red</h1>
<button style="font-size: 10rem;">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem;">我是一个按钮</button>
<style>
.title {

View File

@@ -1,5 +1,5 @@
<h1 class="title">I am red</h1>
<button style="font-size: 10rem;">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem;">我是一个按钮</button>
<style>
.title {

View File

@@ -1,7 +1,7 @@
<template>
<div>
<h1 class="title">I am red</h1>
<button style="font-size: 10rem">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem">我是一个按钮</button>
</div>
</template>

View File

@@ -1,6 +1,6 @@
<template>
<h1 class="title">I am red</h1>
<button style="font-size: 10rem">I am a button</button>
<h1 class="title">我是红色的</h1>
<button style="font-size: 10rem">我是一个按钮</button>
</template>
<style scoped>

View File

@@ -1,4 +1,4 @@
<ul x-data="{ colors: ['red', 'green', 'blue'] }">
<ul x-data="{ colors: ['', '绿', '蓝'] }">
<template x-for="color in colors">
<li x-text="color"></li>
</template>

View File

@@ -10,7 +10,7 @@ import { CommonModule } from "@angular/common";
`,
})
export class ColorsComponent {
colors = ["red", "green", "blue"];
colors = ["", "绿", ""];
}
@NgModule({

View File

@@ -11,5 +11,5 @@ import { Component } from "@angular/core";
`,
})
export class ColorsComponent {
colors = ["red", "green", "blue"];
colors = ["", "绿", ""];
}

View File

@@ -1,3 +1,3 @@
export class Colors {
colors = ["red", "green", "blue"];
colors = ["", "绿", ""];
}

View File

@@ -1,3 +1,3 @@
export class Colors {
colors = ["red", "green", "blue"];
colors = ["", "绿", ""];
}

View File

@@ -1,5 +1,5 @@
<ul>
{{#each (array "red" "green" "blue") as |color|}}
{{#each (array "" "绿" "") as |color|}}
<li>{{color}}</li>
{{/each}}
</ul>

View File

@@ -1,4 +1,4 @@
const colors = ["red", "green", "blue"];
const colors = ["", "绿", "蓝"];
<template>
<ul>

View File

@@ -4,7 +4,7 @@ import { repeat } from "lit/directives/repeat.js";
@customElement("colors-list")
export class ColorsList extends LitElement {
colors = ["red", "green", "blue"];
colors = ["", "绿", ""];
render() {
return html`

View File

@@ -1,5 +1,5 @@
<ul>
<for|color| of=["red", "green", "blue"]>
<for|color| of=["", "绿", "蓝"]>
<li>${color}</li>
</for>
</ul>

View File

@@ -1,7 +1,7 @@
import m from "mithril";
export default function Colors() {
const colors = ["red", "green", "blue"];
const colors = ["", "绿", ""];
return {
view: () =>
m(

View File

@@ -1,7 +1,7 @@
import { component$ } from "@builder.io/qwik";
export const Colors = component$(() => {
const colors = ["red", "green", "blue"];
const colors = ["", "绿", ""];
return (
<ul>
{colors.map((color) => (

View File

@@ -1,5 +1,5 @@
export default function Colors() {
const colors = ["red", "green", "blue"];
const colors = ["", "绿", ""];
return (
<ul>
{colors.map((color) => (

View File

@@ -1,5 +1,5 @@
export component Colors() {
const colors = ["red", "green", "blue"];
const colors = ["", "绿", "蓝"];
<ul>
for (const color of colors) {

View File

@@ -1,7 +1,7 @@
import { For } from "solid-js";
export default function Colors() {
const colors = ["red", "green", "blue"];
const colors = ["", "绿", ""];
return (
<ul>

View File

@@ -1,5 +1,5 @@
<script>
const colors = ["red", "green", "blue"];
const colors = ["", "绿", ""];
</script>
<ul>

View File

@@ -1,5 +1,5 @@
<script>
const colors = ["red", "green", "blue"];
const colors = ["", "绿", ""];
</script>
<ul>

Some files were not shown because too many files have changed in this diff Show More