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

🌐 chore: translate non-English comments to English in src/app/(backend) and src/app/[variants]/(auth)

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
LobeHub Bot
2026-03-09 20:03:13 +08:00
committed by GitHub
parent 1329490306
commit 8a679aa772
9 changed files with 33 additions and 33 deletions

View File

@@ -70,7 +70,7 @@ export async function POST(request: NextRequest) {
{
status: 429,
headers: {
'Retry-After': '37', // 单位:秒
'Retry-After': '37', // unit: seconds
},
},
);

View File

@@ -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: {

View File

@@ -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.');
}

View File

@@ -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'));

View File

@@ -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';

View File

@@ -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;
`,

View File

@@ -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);

View File

@@ -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

View File

@@ -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 === '+';
}