Creation:2024-08-11Last update:2025-06-29
将此文档参考到您的 AI 助手ChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
使用您最喜欢的AI助手总结文档,并引用此页面和AI提供商
此页面的内容已使用 AI 翻译。
查看英文原文的最新版本Edit this doc
If you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy
Copy doc Markdown to clipboard
文档:intlayer 中的 getPathWithoutLocale 函数
描述
如果存在,则从给定的 URL 或路径名中移除语言区域段。它适用于绝对 URL 和相对路径名。
参数
inputUrl: string- 描述:要处理的完整 URL 字符串或路径名。
- 类型:
string
locales: Locales[]- 描述:可选的支持语言区域数组。默认为项目中配置的语言区域。
- 类型:
Locales[]
返回值
- 类型:
string - 描述:不包含语言区域段的 URL 字符串或路径名。
示例用法
typescript
复制代码
复制代码到剪贴板
import { getPathWithoutLocale } from "intlayer";
console.log(getPathWithoutLocale("/dashboard")); // 输出: "/dashboard"
console.log(getPathWithoutLocale("/en/dashboard")); // 输出: "/dashboard"
console.log(getPathWithoutLocale("/fr/dashboard")); // 输出: "/dashboard"
console.log(getPathWithoutLocale("https://example.com/en/dashboard")); // 输出: "https://example.com/dashboard"