|
|
|
|
@ -24,11 +24,6 @@ export const useGetLanguage = () => {
|
|
|
|
|
|
|
|
|
|
return getLanguage(locale)
|
|
|
|
|
}
|
|
|
|
|
export const useGetDocLanguage = () => {
|
|
|
|
|
const { locale } = useI18N()
|
|
|
|
|
|
|
|
|
|
return getDocLanguage(locale)
|
|
|
|
|
}
|
|
|
|
|
export const useGetPricingPageLanguage = () => {
|
|
|
|
|
const { locale } = useI18N()
|
|
|
|
|
|
|
|
|
|
@ -37,15 +32,15 @@ export const useGetPricingPageLanguage = () => {
|
|
|
|
|
|
|
|
|
|
const defaultDocBaseUrl = 'https://docs.dify.ai'
|
|
|
|
|
export const useDocLink = (baseUrl?: string): ((path?: string, pathMap?: { [index: string]: string }) => string) => {
|
|
|
|
|
let baseDocUrl = baseUrl || defaultDocBaseUrl
|
|
|
|
|
baseDocUrl = (baseDocUrl.endsWith('/')) ? baseDocUrl.slice(0, -1) : baseDocUrl
|
|
|
|
|
const { locale } = useI18N()
|
|
|
|
|
const docLanguage = getDocLanguage(locale)
|
|
|
|
|
return (path?: string, pathMap?: { [index: string]: string }): string => {
|
|
|
|
|
const pathUrl = path || ''
|
|
|
|
|
let targetPath = (pathMap) ? pathMap[locale] || pathUrl : pathUrl
|
|
|
|
|
targetPath = (targetPath.startsWith('/')) ? targetPath.slice(0, -1) : targetPath
|
|
|
|
|
return `${baseDocUrl}/${docLanguage}/${targetPath}`
|
|
|
|
|
}
|
|
|
|
|
let baseDocUrl = baseUrl || defaultDocBaseUrl
|
|
|
|
|
baseDocUrl = (baseDocUrl.endsWith('/')) ? baseDocUrl.slice(0, -1) : baseDocUrl
|
|
|
|
|
const { locale } = useI18N()
|
|
|
|
|
const docLanguage = getDocLanguage(locale)
|
|
|
|
|
return (path?: string, pathMap?: { [index: string]: string }): string => {
|
|
|
|
|
const pathUrl = path || ''
|
|
|
|
|
let targetPath = (pathMap) ? pathMap[locale] || pathUrl : pathUrl
|
|
|
|
|
targetPath = (targetPath.startsWith('/')) ? targetPath.slice(1) : targetPath
|
|
|
|
|
return `${baseDocUrl}/${docLanguage}/${targetPath}`
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
export default I18NContext
|
|
|
|
|
|