Skip to content

Commit

Permalink
fluentFormat should check all .ftl files
Browse files Browse the repository at this point in the history
  • Loading branch information
groovecoder committed Oct 16, 2018
1 parent 396548f commit d87b36a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions locale-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const mozlog = require("./log");
const log = mozlog("locale-utils");

const localesDir = path.join("public", "locales");

const availableLanguages = [];
const fluentBundles = {};

Expand All @@ -40,15 +41,21 @@ const LocaleUtils = {
for (const lang of languageDirectories) {
try {
const langBundle = new FluentBundle(lang);
const langFTLSource = fs.readFileSync(path.join(localesDir, lang, "app.ftl"), "utf8");
langBundle.addMessages(langFTLSource);
const ftlFiles = fs.readdirSync(path.join(localesDir, lang)).filter(item => {
return (item.endsWith(".ftl"));
});
for (const file of ftlFiles) {
const langFTLSource = fs.readFileSync(path.join(localesDir, lang, file), "utf8");
langBundle.addMessages(langFTLSource);
}
fluentBundles[lang] = langBundle;
availableLanguages.push(lang);
} catch (e) {
log.error("loadFluentBundle", {stack: e.stack});
}
}
log.info("LocaleUtils.init", {availableLanguages});
log.info("LocaleUtils.init", {fluentBundles});
},

loadLanguagesIntoApp (app) {
Expand Down

0 comments on commit d87b36a

Please sign in to comment.