Skip to content

Commit

Permalink
Merge pull request #252 from nullstack/fix/blog-engine
Browse files Browse the repository at this point in the history
🐛 fix build
  • Loading branch information
AnnyFigueira authored Jan 16, 2023
2 parents 5232e4e + 9b44b88 commit b462b6c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 259 deletions.
Empty file removed i18n/en-US/components/Post.yml
Empty file.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "ISC",
"devDependencies": {
"concurrently": "^7.2.0",
"nullstack": "~0.16.0",
"nullstack": "~0.17.2",
"tailwindcss": "^3.0.0"
},
"scripts": {
Expand Down
22 changes: 12 additions & 10 deletions src/Translatable.njs
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { readFileSync } from 'fs';
import Nullstack from 'nullstack';
import YAML from 'yaml';
import { existsSync, readFileSync } from "fs";
import Nullstack from "nullstack";
import YAML from "yaml";

class Translatable extends Nullstack {

static async geti18nByLocale({ locale }) {
const [name] = this.name.split('_');
const file = readFileSync(`i18n/${locale}/components/${name}.yml`, 'utf-8');
return YAML.parse(file);
const [name] = this.name.split("_");
const translationPath = `i18n/${locale}/components/${name}.yml`;
if (existsSync(translationPath)) {
const file = readFileSync(translationPath, "utf-8");
return YAML.parse(file);
}
return {};
}

async initiate({ page, locale }) {
this.locale = locale;
this.i18n = await this.geti18nByLocale({ locale });
if (this.i18n.title) {
page.description = this.i18n.description;
page.locale = locale || 'en-US';
page.locale = locale || "en-US";
}
}

Expand All @@ -30,7 +33,6 @@ class Translatable extends Nullstack {
this.initiate();
}
}

}

export default Translatable;
export default Translatable;
Loading

0 comments on commit b462b6c

Please sign in to comment.