{"id":20538028,"url":"https://github.com/yoannmoinet/requirejs-i18njs","last_synced_at":"2025-10-19T18:32:56.762Z","repository":{"id":58242458,"uuid":"40265843","full_name":"yoannmoinet/requirejs-i18njs","owner":"yoannmoinet","description":":gb: A requirejs plugin to pre-compile I18NJS' translations","archived":false,"fork":false,"pushed_at":"2015-10-13T03:35:37.000Z","size":196,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T09:31:05.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/yoannmoinet.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-08-05T19:52:06.000Z","updated_at":"2015-11-22T22:29:52.000Z","dependencies_parsed_at":"2022-08-31T00:41:12.408Z","dependency_job_id":null,"html_url":"https://github.com/yoannmoinet/requirejs-i18njs","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/yoannmoinet/requirejs-i18njs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoannmoinet%2Frequirejs-i18njs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoannmoinet%2Frequirejs-i18njs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoannmoinet%2Frequirejs-i18njs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoannmoinet%2Frequirejs-i18njs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoannmoinet","download_url":"https://codeload.github.com/yoannmoinet/requirejs-i18njs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoannmoinet%2Frequirejs-i18njs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279873637,"owners_count":26238011,"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","status":"online","status_checked_at":"2025-10-19T02:00:07.647Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-16T00:43:55.049Z","updated_at":"2025-10-19T18:32:56.735Z","avatar_url":"https://github.com/yoannmoinet.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# requirejs-i18njs\n\n\u003e A [RequireJS](http://requirejs.org/) plugin to pre-compile [I18NJS](https://github.com/yoannmoinet/i18njs)' translations\n\n[![npm version](https://img.shields.io/npm/v/requirejs-i18njs.svg?style=flat)](http://badge.fury.io/js/requirejs-i18njs)\n[![bower version](https://img.shields.io/bower/v/requirejs-i18njs.svg?style=flat)](http://bower.io/search/?q=requirejs-i18njs)\n[![travis](https://travis-ci.org/yoannmoinet/requirejs-i18njs.svg)](https://travis-ci.org/yoannmoinet/requirejs-i18njs)\n\n[![NPM](https://nodei.co/npm-dl/requirejs-i18njs.png?months=1)](https://npmjs.org/package/requirejs-i18njs)\n\n----\n\n## Overview\n\nThis plugins lets you pre-compile the templates in your translation files.\n\nYou won't have any unsafe eval in your production code and will gain some execution time too.\n\n----\n\n## Install\nEither\n\n```node\nnpm install requirejs-i18njs --save\n```\nor\n\n```node\nbower install requirejs-i18njs --save\n```\n\n----\n\n## Test\n\n```node\nnpm test\n```\n\n----\n\n## Usage\n### Configuration\nTo use with [RequireJS](http://requirejs.org/) and [I18NJS](https://github.com/yoannmoinet/i18njs).\n\nYou'll have to configure a new [package](http://requirejs.org/docs/api.html#config-packages) in your RequireJS' config.\n\n```javascript\n({\n    packages: [\n        {\n            'name': 'i18n',\n            // The location where the package is installed\n            'location': './node_modules/requirejs-i18njs/src/',\n            // The main file\n            'main': 'requirejs-i18njs'\n        }\n    ]\n})\n```\n\nYou can also configure some new delimiters for your templates :\n\n```javascript\n({\n    packages: [\n        {\n            'name': 'i18n',\n            'location': './node_modules/requirejs-i18njs/src/',\n            'main': 'requirejs-i18njs',\n            'delimiters': {\n                'evaluate': /\u003c%([\\s\\S]+?)%\u003e/g,\n                'interpolate': /\u003c%=([\\s\\S]+?)%\u003e/g,\n                'escape': /\u003c%-([\\s\\S]+?)%\u003e/g\n            }\n        }\n    ]\n})\n```\nThis will result in pre-compiling delimiters in the form of `\u003c%=interpolate%\u003e`, `\u003c%evaluate%\u003e` or `\u003c%-escape%\u003e`.\n\n### Usage\nYou'll then be able to import your locales with :\n\n```javascript\nvar fr = require('i18n!./locales/fr.json');\ni18njs.add('fr', fr);\n```\n\nAlso, you can tell which language you want to subscribe your strings to by providing the `lang` as a parameter :\n\n```javascript\nrequire('i18n!./locales/fr.json?lang=fr');\n```\nIt will execute `i18n.add('fr', locales);` directly from the plugin.\n\nThe same is also possible to add new defaults to your configuration by providing the `defaults` parameter :\n\n```javascript\nrequire('i18n!./locales/defaults.json?defaults=true');\n```\nIt will execute `i18n.setDefaults(defaults);` directly from the plugin.\n\nFor these to work, you'll need to have [I18NJS](https://github.com/yoannmoinet/i18njs) imported first.\n\nYou can use your [`require.config.deps`](http://requirejs.org/docs/api.html#config-deps) for this :\n```javascript\nrequire.config({\n    // Note that this is at the root of the config.\n    deps: ['i18njs']\n});\n```\nThis will load `i18njs` before everything else.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoannmoinet%2Frequirejs-i18njs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoannmoinet%2Frequirejs-i18njs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoannmoinet%2Frequirejs-i18njs/lists"}