MCPcopy Create free account
hub / github.com/decaporg/decap-cms / getFilePath

Function getFilePath

packages/decap-cms-core/src/lib/i18n.ts:75–91  ·  view source on GitHub ↗
(
  structure: I18N_STRUCTURE,
  extension: string,
  path: string,
  slug: string,
  locale: string,
)

Source from the content-addressed store, hash-verified

73}
74
75export 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
93export function getLocaleFromPath(structure: I18N_STRUCTURE, extension: string, path: string) {
94 switch (structure) {

Callers 3

getFilePathsFunction · 0.85
getI18nFilesFunction · 0.85
getI18nEntryFunction · 0.85

Calls 2

escapeRegExpFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected