Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🌐 chore: translate non-English comments to English in src/app/(backend) (#12836)

LobeHub Bot8a679aa772d7
diff --git a/src/app/(backend)/api/agent/run/route.ts b/src/app/(backend)/api/agent/run/route.ts
index 756b2887a67..5bbb79e00a8 100644
--- a/src/app/(backend)/api/agent/run/route.ts
+++ b/src/app/(backend)/api/agent/run/route.ts
@@ -70,7 +70,7 @@ export async function POST(request: NextRequest) {
{
status: 429,
headers: {
- 'Retry-After': '37', // 单位:秒
+ 'Retry-After': '37', // unit: seconds
},
},
);
diff --git a/src/app/(backend)/market/oidc/[[...segments]]/route.ts b/src/app/(backend)/market/oidc/[[...segments]]/route.ts
index ca5622bf5b9..8a8b92a5373 100644
--- a/src/app/(backend)/market/oidc/[[...segments]]/route.ts
+++ b/src/app/(backend)/market/oidc/[[...segments]]/route.ts
@@ -165,7 +165,7 @@ const handleProxy = async (req: NextRequest, context: RouteContext) => {
try {
const { token } = (await req.json()) as { token?: string };
- // 如果没有 token,尝试使用 trustedClientToken
+ // If no token is provided, attempt to use trustedClientToken
if (!token) {
const trustedClientToken = await getTrustedClientTokenForSession();
@@ -180,7 +180,7 @@ const handleProxy = async (req: NextRequest, context: RouteContext) => {
);
}
- // 使用 trustedClientToken 直接调用 Market userinfo 端点
+ // Use trustedClientToken to directly call the Market userinfo endpoint
const userInfoUrl = `${MARKET_BASE_URL}/lobehub-oidc/userinfo`;
const response = await fetch(userInfoUrl, {
headers: {
diff --git a/src/app/(backend)/oidc/[...oidc]/route.ts b/src/app/(backend)/oidc/[...oidc]/route.ts
index 4d5998161df..ee9fbe876f1 100644
--- a/src/app/(backend)/oidc/[...oidc]/route.ts
+++ b/src/app/(backend)/oidc/[...oidc]/route.ts
@@ -15,7 +15,7 @@ const handler = async (req: NextRequest) => {
log(`Received ${req.method.toUpperCase()} request: %s %s`, req.method, req.url);
log('Path: %s, Pathname: %s', requestUrl.pathname, requestUrl.pathname);
- // 声明响应收集器
+ // Declare the response collector
let responseCollector;
try {
@@ -24,7 +24,7 @@ const handler = async (req: NextRequest) => {
return new NextResponse('OIDC is not enabled', { status: 404 });
}
- // 获取 OIDC Provider 实例
+ // Get the OIDC Provider instance
const provider = await getOIDCProvider();
log(`Calling provider.callback() for ${req.method}`); // Log the method
@@ -41,11 +41,11 @@ const handler = async (req: NextRequest) => {
return;
}
- // 使用辅助方法创建响应收集器
+ // Use helper method to create the response collector
responseCollector = createNodeResponse(resolve);
const nodeResponse = responseCollector.nodeResponse;
- // 使用辅助方法创建 Node.js 请求对象,现在需要 await
+ // Use helper method to create the Node.js request object, now requires await
createNodeRequest(req).then((nodeRequest) => {
log('Calling the obtained middleware...');
middleware(nodeRequest, nodeResponse, (error?: Error) => {
@@ -66,7 +66,7 @@ const handler = async (req: NextRequest) => {
log('Promise surrounding middleware call resolved.');
- // 访问最终的响应状态
+ // Access the final response status
if (!responseCollector) {
throw new Error('ResponseCollector was not initialized.');
}
diff --git a/src/app/(backend)/oidc/callback/desktop/route.ts b/src/app/(backend)/oidc/callback/desktop/route.ts
index 2e4d4ee3b32..f4328c2e195 100644
--- a/src/app/(backend)/oidc/callback/desktop/route.ts
+++ b/src/app/(backend)/oidc/callback/desktop/route.ts
@@ -11,10 +11,10 @@ const log = debug('lobe-oidc:callback:desktop');
const errorPathname = '/oauth/callback/error';
/**
- * 安全地构建重定向URL - 直接使用 APP_URL 作为目标
+ * Safely build redirect URL - directly use APP_URL as target
*/
const buildRedirectUrl = (req: NextRequest, pathname: string): URL => {
- // 使用统一的环境变量管理
+ // Use unified environment variable management
if (appEnv.APP_URL) {
try {
const baseUrl = new URL(appEnv.APP_URL);
@@ -26,7 +26,7 @@ const buildRedirectUrl = (req: NextRequest, pathname: string): URL => {
}
}
- // 后备方案:使用 req.nextUrl
+ // Fallback: use req.nextUrl
log('Warning: APP_URL not configured, using req.nextUrl as fallback');
const fallbackUrl = req.nextUrl.clone();
fallbackUrl.pathname = pathname;
@@ -62,7 +62,7 @@ export const GET = async (req: NextRequest) => {
const successUrl = buildRedirectUrl(req, '/oauth/callback/success');
- // 添加调试日志
+ // Add debug logging
log('Request host header: %s', req.headers.get('host'));
log('Request x-forwarded-host: %s', req.headers.get('x-forwarded-host'));
log('Request x-forwarded-proto: %s', req.headers.get('x-forwarded-proto'));
diff --git a/src/app/(backend)/webapi/user/avatar/[id]/[image]/route.ts b/src/app/(backend)/webapi/user/avatar/[id]/[image]/route.ts
index 46a8779ff52..cda2619d285 100644
--- a/src/app/(backend)/webapi/user/avatar/[id]/[image]/route.ts
+++ b/src/app/(backend)/webapi/user/avatar/[id]/[image]/route.ts
@@ -3,7 +3,7 @@ import { UserService } from '@/server/services/user';
type Params = Promise<{ id: string; image: string }>;
-// 扩展名到内容类型的映射
+// Mapping of file extensions to content types
const CONTENT_TYPE_MAP: Record<string, string> = {
avif: 'image/avif',
bmp: 'image/bmp',
@@ -20,7 +20,7 @@ const CONTENT_TYPE_MAP: Record<string, string> = {
webp: 'image/webp',
};
-// 根据文件扩展名确定内容类型
+// Determine content type based on file extension
function getContentType(filename: string): string {
const extension = filename.split('.').pop()?.toLowerCase() || '';
return CONTENT_TYPE_MAP[extension] || 'application/octet-stream';
diff --git a/src/app/[variants]/(auth)/_layout/style.ts b/src/app/[variants]/(auth)/_layout/style.ts
index 9c6aa8508d4..bbef9655867 100644
--- a/src/app/[variants]/(auth)/_layout/style.ts
+++ b/src/app/[variants]/(auth)/_layout/style.ts
@@ -5,7 +5,7 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({
height: 24px;
`,
- // 内层容器 - 深色模式
+ // Inner container - dark mode
innerContainerDark: css`
position: relative;
@@ -17,7 +17,7 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({
background: ${cssVar.colorBgContainer};
`,
- // 内层容器 - 浅色模式
+ // Inner container - light mode
innerContainerLight: css`
position: relative;
@@ -29,7 +29,7 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({
background: ${cssVar.colorBgContainer};
`,
- // 外层容器
+ // Outer container
outerContainer: css`
position: relative;
`,
diff --git a/src/app/[variants]/(auth)/market-auth-callback/page.tsx b/src/app/[variants]/(auth)/market-auth-callback/page.tsx
index 41a91269938..0887435a171 100644
--- a/src/app/[variants]/(auth)/market-auth-callback/page.tsx
+++ b/src/app/[variants]/(auth)/market-auth-callback/page.tsx
@@ -8,8 +8,8 @@ import { useTranslation } from 'react-i18next';
type CallbackStatus = 'loading' | 'success' | 'error';
/**
- * Market OIDC 授权回调页面
- * 处理从 OIDC 服务器返回的授权码
+ * Market OIDC authorization callback page
+ * Handles the authorization code returned from the OIDC server
*/
const MarketAuthCallbackPage = () => {
const { t } = useTranslation('marketAuth');
@@ -31,7 +31,7 @@ const MarketAuthCallbackPage = () => {
setStatus('error');
setMessage(t('callback.messages.authFailed', { error: errorDescription || error }));
- // 向父窗口发送错误消息
+ // Send error message to parent window
if (window.opener) {
window.opener.postMessage(
{
@@ -49,7 +49,7 @@ const MarketAuthCallbackPage = () => {
setStatus('success');
setMessage(t('callback.messages.successWithRedirect'));
- // 向父窗口发送成功消息
+ // Send success message to parent window
if (window.opener) {
window.opener.postMessage(
{
@@ -61,7 +61,7 @@ const MarketAuthCallbackPage = () => {
);
}
- // 开始倒计时并在3秒后关闭窗口
+ // Start countdown and close window after 3 seconds
let timeLeft = 3;
setCountdown(timeLeft);
diff --git a/src/app/[variants]/(auth)/oauth/consent/[uid]/page.tsx b/src/app/[variants]/(auth)/oauth/consent/[uid]/page.tsx
index ef68a4f858c..ed6b38b7fd7 100644
--- a/src/app/[variants]/(auth)/oauth/consent/[uid]/page.tsx
+++ b/src/app/[variants]/(auth)/oauth/consent/[uid]/page.tsx
@@ -17,10 +17,10 @@ const InteractionPage = async (props: { params: Promise<{ uid: string }> }) => {
try {
const oidcService = await OIDCService.initialize();
- // 获取交互详情,传入请求和响应对象
+ // Get interaction details, passing request and response objects
const details = await oidcService.getInteractionDetails(uid);
- // 支持 login 和 consent 类型的交互
+ // Support login and consent type interactions
if (details.prompt.name !== 'consent' && details.prompt.name !== 'login') {
return (
<ConsentClientError
@@ -33,7 +33,7 @@ const InteractionPage = async (props: { params: Promise<{ uid: string }> }) => {
);
}
- // 获取客户端 ID 和授权范围
+ // Get client ID and authorization scopes
const clientId = (details.params.client_id as string) || 'unknown';
const scopes = (details.params.scope as string)?.split(' ') || [];
@@ -44,7 +44,7 @@ const InteractionPage = async (props: { params: Promise<{ uid: string }> }) => {
isFirstParty: defaultClients.map((c) => c.client_id).includes(clientId),
logo: clientDetail?.logo_uri,
};
- // 渲染客户端组件,无论是 login 还是 consent 类型
+ // Render client component regardless of login or consent type
if (details.prompt.name === 'login')
return <Login clientMetadata={clientMetadata} uid={params.uid} />;
@@ -59,9 +59,9 @@ const InteractionPage = async (props: { params: Promise<{ uid: string }> }) => {
);
} catch (error) {
console.error('Error handling OIDC interaction:', error);
- // 确保错误处理能正确显示
+ // Ensure error handling can display correctly
const errorMessage = error instanceof Error ? error.message : undefined;
- // 检查是否是 'interaction session not found' 错误,可以给用户更友好的提示
+ // Check if it is an 'interaction session not found' error for a more user-friendly message
if (errorMessage?.includes('interaction session not found')) {
return (
<ConsentClientError
diff --git a/src/config/featureFlags/utils/parser.ts b/src/config/featureFlags/utils/parser.ts
index 92c3deae128..06216b007e3 100644
--- a/src/config/featureFlags/utils/parser.ts
+++ b/src/config/featureFlags/utils/parser.ts
@@ -2,16 +2,16 @@ import { type IFeatureFlags } from '../schema';
import { FeatureFlagsSchema } from '../schema';
/**
- * 解析环境变量中的特性标志字符串。
- * @param flagString 从环境变量中读取的特性标志字符串。
- * @returns 解析后的特性标志对象。
+ * Parses the feature flag string from environment variables.
+ * @param flagString The feature flag string read from environment variables.
+ * @returns The parsed feature flags object.
*/
export function parseFeatureFlag(flagString?: string): Partial<IFeatureFlags> {
const flags: Partial<IFeatureFlags> = {};
if (!flagString) return flags;
- // 将中文逗号替换为英文逗号,并按逗号分割字符串
+ // Replace Chinese commas with English commas and split string by comma
const flagArray = flagString.trim().replaceAll(',', ',').split(',');
for (let flag of flagArray) {
@@ -22,7 +22,7 @@ export function parseFeatureFlag(flagString?: string): Partial<IFeatureFlags> {
const featureKey = key as keyof IFeatureFlags;
- // 检查 key 是否存在于 FeatureFlagsSchema 中
+ // Check if the key exists in FeatureFlagsSchema
if (FeatureFlagsSchema.shape[featureKey]) {
flags[featureKey] = operation === '+';
}