mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-27 19:46:24 +00:00
⚡️ feat: refactor sorting parameters in post listing API and components
- Renamed `orderedBy` to `orderBy` and `reverse` to `desc` in ListPostsParams interface and related functions. - Updated all usages of the sorting parameters in the post listing logic to reflect the new naming convention. feat: add user-related API functions - Implemented `getLoginUser` and `getUserById` functions in the user API to fetch user details. - Enhanced user model to include `language` property. feat: integrate next-intl for internationalization - Added `next-intl` plugin to Next.js configuration for improved localization support. - Removed previous i18n implementation and replaced it with a new structure using JSON files for translations. - Created locale files for English, Japanese, and Chinese with basic translations. - Implemented a request configuration to handle user locales and messages dynamically. fix: clean up unused imports and code - Removed unused i18n utility functions and language settings from device context. - Cleaned up commented-out code in blog card component and sidebar. chore: update dependencies - Added `deepmerge` for merging locale messages. - Updated package.json and pnpm-lock.yaml to reflect new dependencies.
This commit is contained in:
@ -1,27 +0,0 @@
|
||||
import { initReactI18next } from "react-i18next";
|
||||
|
||||
import i18n from "i18next";
|
||||
|
||||
import resources from "./locales";
|
||||
|
||||
export const getDefaultLang = () => {
|
||||
if (typeof window !== "undefined") {
|
||||
return (
|
||||
localStorage.getItem("language") ||
|
||||
navigator.language.replace("_", "-") || // 保证格式
|
||||
"zh-CN"
|
||||
);
|
||||
}
|
||||
return "zh-CN";
|
||||
};
|
||||
|
||||
i18n.use(initReactI18next).init({
|
||||
resources: resources,
|
||||
lng: getDefaultLang(),
|
||||
fallbackLng: "zh-CN",
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
});
|
||||
|
||||
export default i18n;
|
@ -1,30 +0,0 @@
|
||||
const resources = {
|
||||
translation: {
|
||||
name: "English",
|
||||
hello: "Hello",
|
||||
login: {
|
||||
login: "Login",
|
||||
failed: "Login failed",
|
||||
forgotPassword: "Forgot password?",
|
||||
username: "Username",
|
||||
usernameOrEmail: "Username or Email",
|
||||
password: "Password",
|
||||
remember: "Remember this device",
|
||||
captcha: {
|
||||
no: "No captcha required",
|
||||
failed: "Captcha verification failed, please try again",
|
||||
fetchFailed: "Failed to fetch captcha, please try again later",
|
||||
processing: "Waiting for verification...",
|
||||
reCaptchaProcessing: "Processing reCAPTCHA verification, please wait...",
|
||||
reCaptchaFailed: "reCAPTCHA verification failed, please try again",
|
||||
reCaptchaSuccess: "reCAPTCHA verification successful",
|
||||
},
|
||||
oidc: {
|
||||
fetchFailed: "Failed to fetch OIDC providers, please try again later",
|
||||
use: "Login with {{provider}}",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default resources;
|
@ -1,9 +0,0 @@
|
||||
import enUS from "./en-us";
|
||||
import zhCN from "./zh-cn";
|
||||
|
||||
const resources = {
|
||||
"zh-CN": zhCN,
|
||||
"en-US": enUS,
|
||||
};
|
||||
|
||||
export default resources;
|
@ -1,30 +0,0 @@
|
||||
const resources = {
|
||||
translation: {
|
||||
name: "中文",
|
||||
hello: "你好",
|
||||
login: {
|
||||
login: "登录",
|
||||
failed: "登录失败",
|
||||
forgotPassword: "忘了密码?",
|
||||
username: "用户名",
|
||||
usernameOrEmail: "用户名或邮箱",
|
||||
password: "密码",
|
||||
remember: "记住这个设备",
|
||||
captcha: {
|
||||
no: "无需进行机器人挑战",
|
||||
failed: "机器人挑战失败,请重试",
|
||||
fetchFailed: "获取验证码失败,请稍后再试",
|
||||
processing: "等待验证...",
|
||||
reCaptchaProcessing: "正在处理 reCAPTCHA 验证,请稍候...",
|
||||
reCaptchaFailed: "reCAPTCHA 验证失败,请重试",
|
||||
reCaptchaSuccess: "reCAPTCHA 验证成功",
|
||||
},
|
||||
oidc: {
|
||||
fetchFailed: "获取 OIDC 提供商失败,请稍后再试",
|
||||
use: "使用 {{provider}} 登录",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default resources;
|
Reference in New Issue
Block a user