{"id":19448227,"url":"https://github.com/csbun/fis-prepackager-i18n","last_synced_at":"2026-06-07T21:32:24.926Z","repository":{"id":57237105,"uuid":"44788009","full_name":"csbun/fis-prepackager-i18n","owner":"csbun","description":"A i18n preprocessor for fis","archived":false,"fork":false,"pushed_at":"2016-02-22T10:45:12.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-08T15:47:21.133Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csbun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-23T03:14:25.000Z","updated_at":"2016-01-13T10:40:52.000Z","dependencies_parsed_at":"2022-08-26T14:04:11.300Z","dependency_job_id":null,"html_url":"https://github.com/csbun/fis-prepackager-i18n","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csbun%2Ffis-prepackager-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csbun%2Ffis-prepackager-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csbun%2Ffis-prepackager-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csbun%2Ffis-prepackager-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csbun","download_url":"https://codeload.github.com/csbun/fis-prepackager-i18n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240636664,"owners_count":19832922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-10T16:25:06.534Z","updated_at":"2025-02-25T08:52:51.840Z","avatar_url":"https://github.com/csbun.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fis-prepackager-i18n\n\nA i18n prepackager for [fis](http://fex-team.github.io/fis-site/)/[Scrat](http://scrat.io) using [ejs](https://www.npmjs.com/package/ejs)\n\n\n## Usage\n\n### i18n\n\n```\nsrc\n├── fis-conf.js\n├── i18n-folder-name\n│   ├── en.json\n│   ├── zh.json\n│   └── ...\n├── components\n│   ├── header\n│   │   └── header.html\n│   ├── some-section\n│   │   └── some-section.html\n│   └── ...\n├── package.json\n└── views\n    ├── index\n    │   ├── index.less\n    │   ├── index.js\n    │   ├── index.html\n    │   └── ...\n    ├── some\n    │   ├── some.html\n    │   └── ...\n    └── ...(more views)\n```\n\n### fis-conf.js\n\n```javascript\nfis.config.set('settings.prepackager.i18n', {\n    folder: 'i18n-folder-name',\n    defaultI18n: 'en',\n    connector: '_',\n    // You can use all [Ejs Options](https://www.npmjs.com/package/ejs#options) here.\n    ejs: {\n        delimiter: '%'\n    }\n});\n```\n\n#### fis2\n\n```javascript\nfis.config.set('modules.prepackager', 'i18n');\nfis.config.set('roadmap.path', [\n    {\n        // source html\n        reg: 'views/**/*.html',\n        // `isLayout` should be `TRUE`\n        isLayout: true\n    },\n    {\n        // other html `isLayout` != `TRUE`\n        reg: '**/*.html'\n    }\n]);\n```\n\n#### fis3\n\n```javascript\nfis.match('*.html', {\n    release: '$0'\n    // other html `isLayout` != `TRUE`\n});\nfis.match('views/**/*.html', {\n    release: '$0',\n    // `isLayout` should be `TRUE`\n    isLayout: true\n});\nfis.match('::package', {\n    prepackager: fis.plugin('i18n')\n});\n```\n\n## Example\n\n### i18n\n\n- en.json\n\n```\n{\n    \"id\": \"EN\",\n    \"hello\": \"hello\",\n    \"world\": \"world\"\n}\n```\n\n- zh.json\n\n```\n{\n    \"id\": \"ZH\",\n    \"hello\": \"你好\",\n    \"world\": \"世界\"\n}\n```\n\n### html\n\n- components/header/header.html\n\n```html\n\u003cdiv class=\"header\"\u003e\n    \u003c%= hello %\u003e\n\u003c/div\u003e\n```\n\n- components/some-section/some-section.html\n\n```html\n\u003cdiv data-cmp=\"some-section\"\u003e\n    \u003c%= world %\u003e\n\u003c/div\u003e\n```\n\n- views/index/index.html\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003eview - index\u003c/title\u003e\n    \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"index.less\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003e\n    \u003c% if (id === 'en') { %\u003e\n        here is `\u003c%= id %\u003e`\n    \u003c% } else { %\u003e\n        这里是 `\u003c%= id %\u003e`\n    \u003c% } %\u003e\n    \u003c/h1\u003e\n\n    \u003c!-- Components here --\u003e\n    {{{unit name=\"header\"}}}\n    {{{unit name=\"some-section\"}}}\n    \u003c!-- Components end --\u003e\n\n    \u003cscript type=\"text/javascript\" src=\"index.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### output\n\n- views/index/index.html (defaultI18n == 'en')\n- views/index/index_en.html\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003eview - index\u003c/title\u003e\n    \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"index.css\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003e\n        here is `EN`\n    \u003c/h1\u003e\n\n    \u003c!-- Components here --\u003e\n    \u003cdiv class=\"header\"\u003e\n        hello\n    \u003c/div\u003e\n    \n    \u003cdiv data-cmp=\"some-section\"\u003e\n        world\n    \u003c/div\u003e\n    \u003c!-- Components end --\u003e\n\n    \u003cscript type=\"text/javascript\" src=\"index.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n- views/index/index_zh.html\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003eview - index\u003c/title\u003e\n    \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"index.css\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003e\n        这里是 `ZH`\n    \u003c/h1\u003e\n\n    \u003c!-- Components here --\u003e\n    \u003cdiv class=\"header\"\u003e\n        你好\n    \u003c/div\u003e\n    \n    \u003cdiv data-cmp=\"some-section\"\u003e\n        世界\n    \u003c/div\u003e\n    \u003c!-- Components end --\u003e\n\n    \u003cscript type=\"text/javascript\" src=\"index.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsbun%2Ffis-prepackager-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsbun%2Ffis-prepackager-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsbun%2Ffis-prepackager-i18n/lists"}