mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-26 14:27:20 +00:00
![dependabot[bot]](/assets/img/avatar_default.png)
* Bump del from 4.1.1 to 7.0.0 Bumps [del](https://github.com/sindresorhus/del) from 4.1.1 to 7.0.0. - [Release notes](https://github.com/sindresorhus/del/releases) - [Commits](https://github.com/sindresorhus/del/compare/v4.1.1...v7.0.0) --- updated-dependencies: - dependency-name: del dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Deduplicate dependencies * Adjust to ESM-only and API changes Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Steve Repsher <steverep@users.noreply.github.com>
73 lines
2.0 KiB
JavaScript
Executable File
73 lines
2.0 KiB
JavaScript
Executable File
const del = import("del");
|
|
const path = require("path");
|
|
const gulp = require("gulp");
|
|
const fs = require("fs");
|
|
const paths = require("../paths");
|
|
|
|
const outDir = "build/locale-data";
|
|
|
|
gulp.task("clean-locale-data", async () => (await del).deleteSync([outDir]));
|
|
|
|
gulp.task("ensure-locale-data-build-dir", (done) => {
|
|
if (!fs.existsSync(outDir)) {
|
|
fs.mkdirSync(outDir, { recursive: true });
|
|
}
|
|
done();
|
|
});
|
|
|
|
const modules = {
|
|
"intl-relativetimeformat": "RelativeTimeFormat",
|
|
"intl-datetimeformat": "DateTimeFormat",
|
|
"intl-numberformat": "NumberFormat",
|
|
};
|
|
|
|
gulp.task("create-locale-data", (done) => {
|
|
const translationMeta = JSON.parse(
|
|
fs.readFileSync(
|
|
path.join(paths.translations_src, "translationMetadata.json")
|
|
)
|
|
);
|
|
Object.entries(modules).forEach(([module, className]) => {
|
|
Object.keys(translationMeta).forEach((lang) => {
|
|
try {
|
|
const localeData = String(
|
|
fs.readFileSync(
|
|
require.resolve(`@formatjs/${module}/locale-data/${lang}.js`)
|
|
)
|
|
)
|
|
.replace(
|
|
new RegExp(
|
|
`\\/\\*\\s*@generated\\s*\\*\\/\\s*\\/\\/\\s*prettier-ignore\\s*if\\s*\\(Intl\\.${className}\\s*&&\\s*typeof\\s*Intl\\.${className}\\.__addLocaleData\\s*===\\s*'function'\\)\\s*{\\s*Intl\\.${className}\\.__addLocaleData\\(`,
|
|
"im"
|
|
),
|
|
""
|
|
)
|
|
.replace(/\)\s*}/im, "");
|
|
// make sure we have valid JSON
|
|
JSON.parse(localeData);
|
|
if (!fs.existsSync(path.join(outDir, module))) {
|
|
fs.mkdirSync(path.join(outDir, module), { recursive: true });
|
|
}
|
|
fs.writeFileSync(
|
|
path.join(outDir, `${module}/${lang}.json`),
|
|
localeData
|
|
);
|
|
} catch (e) {
|
|
if (e.code !== "MODULE_NOT_FOUND") {
|
|
throw e;
|
|
}
|
|
}
|
|
});
|
|
done();
|
|
});
|
|
});
|
|
|
|
gulp.task(
|
|
"build-locale-data",
|
|
gulp.series(
|
|
"clean-locale-data",
|
|
"ensure-locale-data-build-dir",
|
|
"create-locale-data"
|
|
)
|
|
);
|