mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-08 00:50:59 +01:00
Merge pull request #916 from sergitost10/feat/catalan-translation
feat(i18n): add Catalan language support
This commit is contained in:
+5
-3
@@ -28,6 +28,7 @@ export const supportedLanguages = [
|
||||
'ja',
|
||||
'uk',
|
||||
'sk',
|
||||
'ca',
|
||||
] as const;
|
||||
export type SupportedLanguage = (typeof supportedLanguages)[number];
|
||||
|
||||
@@ -54,6 +55,7 @@ export const languageNames: Record<SupportedLanguage, string> = {
|
||||
ja: '日本語',
|
||||
uk: 'Українська',
|
||||
sk: 'Slovenčina',
|
||||
ca: 'Català',
|
||||
};
|
||||
|
||||
export const getLanguageFromUrl = (): SupportedLanguage => {
|
||||
@@ -69,7 +71,7 @@ export const getLanguageFromUrl = (): SupportedLanguage => {
|
||||
}
|
||||
|
||||
const langMatch = path.match(
|
||||
/^\/(en|ar|fr|es|de|zh|zh-TW|vi|tr|id|it|pt|nl|be|da|ko|sv|ru|ja|uk|sk)(?:\/|$)/
|
||||
/^\/(en|ar|fr|es|de|zh|zh-TW|vi|tr|id|it|pt|nl|be|da|ko|sv|ru|ja|uk|sk|ca)(?:\/|$)/
|
||||
);
|
||||
if (
|
||||
langMatch &&
|
||||
@@ -166,7 +168,7 @@ export const changeLanguage = (lang: SupportedLanguage): void => {
|
||||
|
||||
let pagePathWithoutLang = relativePath;
|
||||
const langPrefixMatch = relativePath.match(
|
||||
/^\/(en|ar|fr|es|de|zh|zh-TW|vi|tr|id|it|pt|nl|be|da|ko|sv|ru|ja|uk|sk)(\/.*)?$/
|
||||
/^\/(en|ar|fr|es|de|zh|zh-TW|vi|tr|id|it|pt|nl|be|da|ko|sv|ru|ja|uk|sk|ca)(\/.*)?$/
|
||||
);
|
||||
if (langPrefixMatch) {
|
||||
pagePathWithoutLang = langPrefixMatch[2] || '/';
|
||||
@@ -261,7 +263,7 @@ export const rewriteLinks = (): void => {
|
||||
}
|
||||
|
||||
const langPrefixRegex = new RegExp(
|
||||
`^(${basePath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})?/?(en|ar|fr|es|de|zh|zh-TW|vi|tr|id|it|pt|nl|be|da|ko|sv|ru|ja|uk|sk)(/|$)`
|
||||
`^(${basePath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})?/?(en|ar|fr|es|de|zh|zh-TW|vi|tr|id|it|pt|nl|be|da|ko|sv|ru|ja|uk|sk|ca)(/|$)`
|
||||
);
|
||||
if (langPrefixRegex.test(href)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user