{"id":20441208,"url":"https://github.com/thomas-darling/gulp-locale-filter","last_synced_at":"2026-04-19T01:38:14.449Z","repository":{"id":57258157,"uuid":"75664733","full_name":"thomas-darling/gulp-locale-filter","owner":"thomas-darling","description":"Gulp plugin that filters files in the stream based on locale or language codes in the file paths.","archived":false,"fork":false,"pushed_at":"2017-06-25T15:24:59.000Z","size":25,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-19T01:38:13.283Z","etag":null,"topics":["filter","g11n","globalization","gulp","gulp-plugin","i18n","internationalization","l10n","locale","localization"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomas-darling.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-05T20:46:18.000Z","updated_at":"2017-11-01T14:13:33.000Z","dependencies_parsed_at":"2022-08-25T19:11:02.985Z","dependency_job_id":null,"html_url":"https://github.com/thomas-darling/gulp-locale-filter","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/thomas-darling/gulp-locale-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-darling%2Fgulp-locale-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-darling%2Fgulp-locale-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-darling%2Fgulp-locale-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-darling%2Fgulp-locale-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomas-darling","download_url":"https://codeload.github.com/thomas-darling/gulp-locale-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-darling%2Fgulp-locale-filter/sbom","scorecard":{"id":882157,"data":{"date":"2025-08-11","repo":{"name":"github.com/thomas-darling/gulp-locale-filter","commit":"bf5e1017dc8cc98451b863428a7e0998c2ddf095"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-24T08:36:56.153Z","repository_id":57258157,"created_at":"2025-08-24T08:36:56.154Z","updated_at":"2025-08-24T08:36:56.154Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31991720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"ssl_error","status_checked_at":"2026-04-18T20:23:29.375Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filter","g11n","globalization","gulp","gulp-plugin","i18n","internationalization","l10n","locale","localization"],"created_at":"2024-11-15T09:30:44.211Z","updated_at":"2026-04-19T01:38:14.424Z","avatar_url":"https://github.com/thomas-darling.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿gulp-locale-filter\n===============\n\n[![Version](https://img.shields.io/npm/v/gulp-locale-filter.svg)](https://www.npmjs.org/package/gulp-locale-filter)\n[![Downloads](https://img.shields.io/npm/dm/gulp-locale-filter.svg)](https://www.npmjs.com/package/gulp-locale-filter)\n[![Try on RunKit](https://badge.runkitcdn.com/gulp-locale-filter.svg)](https://runkit.com/npm/gulp-locale-filter)\n\nGulp plugin that filters the files in the stream based on locale or language codes in the file paths, optionally\nrenaming the files to their base name, without the code. Use this to e.g. localize the output of a build process,\nby filtering to only the file variants that are relevant for the target locale.\n\nWhen identifying the locale of a file, the plugin evaluates each segment in the relative file path, stopping when it\nfinds the first segment, if any, that matches, or is postfixed with, a language or locale code, or if a default base\nname is specified, matches that. This means, that given a file path such as `./foo/en-us/da-dk.html`, the locale would\nbe identified as `en-us`. If the file path contains no locale info, the file is considered a _base_ file, and is only\npassed through if there exist no file variants matching the target locale. If both a matching language and locale variant\nis found, the locale variant will take precedence. Note that this plugin does not _replace_ files in the stream - it\nsimply _filters_ the files that pass through, such that only the best matches are let through, and optionally renamed.\n\nLocale codes are expected to be in the [IEFT language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format,\nand must be composed of a single primary 2-letter language subtag, an optional 4-letter script subtag, and a 2-letter\nregion subtag. Language codes are expected to be a 2-letters. Note that the matching is case-sensitive, meaning that\nthe casing of the target locale code specified in the `filter` config must be the same as the casing of locale codes\nin the file paths.\n\nYou may also want to look at the plugins:\n\n* [gulp-tree-filter](https://www.npmjs.com/package/gulp-tree-filter) for filtering files based using include and exclude globs defined in config files located within the folder tree.\nUse this to e.g. prevent localizable content from being extracted from unfinished features.\n\n* [gulp-locale-filter](https://www.npmjs.com/package/gulp-locale-filter) for filtering files based on locale or language codes in the file path.\nUse this to e.g. include only the locale config files that are relevant for the target locale when creating a localized build.\n\n* [gulp-replace](https://www.npmjs.com/package/gulp-replace) for replacing text content in files.\nUse this to e.g. replace placeholder such as `{{locale}}` in templates and CSS files with the actual target locale code when creating a localized build.\n\n## Examples\n\nAssume we have the following Gulp task for localizing the contents of a folder:\n\n```javascript\nvar targetLocaleCode = \"da-dk\";\n\nvar pluginConfig = { };\n\ngulp.task(\"localize\", function ()\n{\n    return gulp\n        .src(\"./sources/**\")\n        .pipe(localeFilter(pluginConfig).filter({\n            localeCode: targetLocaleCode,\n            renameToBaseName: false\n        }))\n        .pipe(gulp.dest(\"./artifacts/\" + targetLocaleCode));\n});\n```\n\n### Files or folders with a locale postfix\n\nGiven a `sources` folder containing the files:\n```\nfoo.html\nbar.html\nbar.en-us.html\nbar.da-dk.html\n```\n\nThe `artifacts/da-dk` folder would, after running the task, contain only the files:\n```\nfoo.html\nbar.da-dk.html\n```\n\nOr, if the `renameToBaseName` plugin option is enabled:\n```\nfoo.html\nbar.html // this is actually 'bar.da-dk.html', renamed to its base name\n```\n\n### Locale folders\n\nGiven a `sources` folder containing locale-specific subfolders:\n```\n- foo\n    foo.html\n- da-dk\n    bar.html\n- en-us\n    bar.html\n```\n\nThe `artifacts/da-dk` folder would, after running the task, contain only the files:\n```\n- foo\n    foo.html\n- da-dk\n    bar.html\n```\n\nOr, if the `renameToBaseName` plugin option is enabled and `defaultBaseName` is set to \"locale\":\n```\n- foo\n    foo.html\n- locale // this is actually 'da-dk', renamed to its default base name\n    bar.html\n```\n\n### Locale files\n\nGiven a `sources` folder containing locale-specific files:\n```\nfoo.html\nda-dk.html\nen-us.html\n```\n\nThe `artifacts/da-dk` folder would, after running the task, contain only the files:\n```\nfoo.html\nda-dk.html\n```\n\nOr, if the `renameToBaseName` option is enabled and `defaultBaseName` is set to `locale`:\n```\nfoo.html\nlocale.html // this is actually 'da-dk.html', renamed to its default base name\n```\n\n### More options\n\nThis plugin can support more scenarios than the above examples, including e.g. filtering based on language codes.\nPlease review, and carefully consider the implications of, the available configuration options and default values.\nSee also the example in the repository, which demonstrates how this works.\n\n## How to use the plugin\n\nInstall the plugin as a dev dependency:\n\n```\nnpm install gulp-locale-filter --save-dev\n```\n\nUse the plugin:\n\n```javascript\n// Import the plugin:\nvar localeFilter = require(\"gulp-locale-filter\");\n\n// Define the plugin configuration:\nvar pluginConfig = { };\n\n// Use the command provided by the plugin in your gulp tasks:\n.pipe(localeFilter(pluginConfig).filter(filterConfig))\n\n```\n\n## Plugin config\n\nThe following is the interface for the config object, that may optionally be passed to the plugin function.\n\n```typescript\ninterface IPluginConfig\n{\n    /**\n     * True to filter folders whose name exactly matches locale codes,\n     * otherwise false. Alternatively you may specify the RegExp used for\n     * matching, which must contain exactly one capture group, capturing\n     * the locale code.\n     * Default is true.\n     */\n    matchLocaleFolders?: boolean|RegExp;\n\n    /**\n     * True to filter files whose name exactly matches locale codes,\n     * otherwise false. Alternatively you may specify the RegExp used for\n     * matching, which must contain exactly one capture group, capturing\n     * the locale code.\n     * Default is true.\n     */\n    matchLocaleFiles?: boolean|RegExp;\n\n    /**\n     * True to filter files whose names are postfixed with a '.' followed\n     * by a locale code, otherwise false. Alternatively you may specify the\n     * RegExp used for matching, which must contain exactly one capture\n     * group, capturing the locale code.\n     * Default is true.\n     */\n    matchLocalePostfixes?: boolean|RegExp;\n\n    /**\n     * True to filter folders whose name exactly matches language codes,\n     * otherwise false. Alternatively you may specify the RegExp used for\n     * matching, which must contain exactly one capture group, capturing\n     * the language code. Note that if a folder matching the full locale\n     * also exists, that will take precedence.\n     * Default is false.\n     */\n    matchLanguageFolders?: boolean|RegExp;\n\n    /**\n     * True to filter files whose name exactly matches language codes,\n     * otherwise false. Alternatively you may specify the RegExp used for\n     * matching, which must contain exactly one capture group, capturing\n     * the language code. Note that if a file matching the full locale\n     * also exists, that will take precedence.\n     * Default is false.\n     */\n    matchLanguageFiles?: boolean|RegExp;\n\n    /**\n     * True to filter files whose names are postfixed with a '.' followed\n     * by a language code, otherwise false. Alternatively you may specify\n     * the RegExp used for matching, which must contain exactly one capture\n     * group, capturing the language code. Note that if a file or folder\n     * matching the full locale also exists, that will take precedence.\n     * Default is false.\n     */\n    matchLanguagePostfixes?: boolean|RegExp;\n\n    /**\n     * True to only match files and folders if a corresponding base file or\n     * folder exist, otherwise false. Note that if enabled, locale files and\n     * folders will only be matched if a default base name is specified.\n     * Default is false.\n     */\n    matchOnlyIfBaseNameExists?: boolean;\n\n    /**\n     * The base name to look for when matching files and folders whose name\n     * exactly matches a locale or language code, with the requirement that\n     * the base name must also exist, or when renaming such files and folders\n     * to their base name.\n     * Default is undefined, meaning that such files and folders will not be\n     * renamed, and if the base name must\n     * exist, not matched.\n     */\n    defaultBaseName?: string;\n\n    /**\n     * The list of expected file name extensions. By default, everything\n     * after the last '.' is assumed to be the file name extension, but in\n     * some cases, such as '.js.map' and '.css.map' files, this could lead\n     * to incorrect locale or language matches. To avoid this, any such\n     * extensions must be listed here.\n     * Default is [\".js.map\", \".css.map\"].\n     */\n    fileNameExtensions?: string[];\n\n    /**\n     * True to enable caching of file system lookups, otherwise false.\n     * Default is true.\n     */\n    cache?: boolean;\n\n    /**\n     * True to enable debug logging, otherwise false.\n     * Default is false.\n     */\n    debug?: boolean;\n}\n```\n\n## The `export` command\n\nExample:\n\n```javascript\n\n// The locale for which the source files should be localized.\nvar targetLocaleCode = \"da-dk\";\n\n/**\n * Gulp task that localizes the build artifacts into locale specific builds.\n */\ngulp.task(\"localize\", function ()\n{\n    return gulp\n\n        // Get the source files.\n        .src(\"./sources/**\")\n\n        // Filter the stream to include only the files relevant for the\n        // configured locale.\n        .pipe(localeFilter(pluginConfig).filter(\n        {\n            localeCode: targetLocaleCode,\n            renameToBaseName: true\n        }))\n\n        // Write the destination file to the localized artifacts folder.\n        .pipe(gulp.dest(\"./artifacts/\" + targetLocaleCode));\n});\n```\n\n### The `filter` config\n\nThe following is the interface for the config object, that may optionally be passed to the `filter` function.\n\n```typescript\ninterface IFilterCommandConfig\n{\n    /**\n     * The locale code for which files should be passed through,\n     * or undefined to pass through only base files.\n     * Default is undefined.\n     */\n    localeCode?: string;\n\n    /**\n     * True to rename the files that are passed through to their\n     * base name, otherwise false.\n     * Default is false.\n     */\n    renameToBaseName?: boolean;\n}\n```\n\nEnjoy, and please report any issues in the issue tracker :-)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-darling%2Fgulp-locale-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomas-darling%2Fgulp-locale-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-darling%2Fgulp-locale-filter/lists"}