Skip to content

Commit

Permalink
No longer allow translation files with no domain
Browse files Browse the repository at this point in the history
  • Loading branch information
LorisSigrist committed Oct 19, 2023
1 parent 6224890 commit 088ceb8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,13 @@ export function t18sCore(pluginConfig) {
/**
* Categorizes to which locale & domain a given file belongs.
* @param {string} path
* @returns {{locale: string, domain: string}}
*/
const categorizeFile = (path) => {
const filename = basename(path).split(".").slice(0, -1).join(".");

const [first, second] = filename.split(".");
if (!first) throw new Error(`Could not determine locale for ${path}`);
if (!second) return { locale: first, domain: config.defaultDomain };
if (!second) throw new Error(`Could not determine domain for ${path}`);
return { locale: second, domain: first };
};

Expand Down

0 comments on commit 088ceb8

Please sign in to comment.