( structure: I18N_STRUCTURE, extension: string, path: string, slug: string, locale: string, )
| 73 | } |
| 74 | |
| 75 | export function getFilePath( |
| 76 | structure: I18N_STRUCTURE, |
| 77 | extension: string, |
| 78 | path: string, |
| 79 | slug: string, |
| 80 | locale: string, |
| 81 | ) { |
| 82 | switch (structure) { |
| 83 | case I18N_STRUCTURE.MULTIPLE_FOLDERS: |
| 84 | return path.replace(`/${slug}`, `/${locale}/${slug}`); |
| 85 | case I18N_STRUCTURE.MULTIPLE_FILES: |
| 86 | return path.replace(new RegExp(`${escapeRegExp(extension)}$`), `${locale}.${extension}`); |
| 87 | case I18N_STRUCTURE.SINGLE_FILE: |
| 88 | default: |
| 89 | return path; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | export function getLocaleFromPath(structure: I18N_STRUCTURE, extension: string, path: string) { |
| 94 | switch (structure) { |
no test coverage detected