{"id":16184606,"url":"https://github.com/rmariuzzo/laravel-localization-loader","last_synced_at":"2025-03-16T10:31:52.849Z","repository":{"id":54548365,"uuid":"84954453","full_name":"rmariuzzo/laravel-localization-loader","owner":"rmariuzzo","description":"Laravel Localization loader for webpack. Convert Laravel Translation strings to JavaScript Objects.","archived":false,"fork":false,"pushed_at":"2019-10-26T09:05:50.000Z","size":83,"stargazers_count":69,"open_issues_count":8,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-27T07:44:56.083Z","etag":null,"topics":["laravel-localization","webpack-loader"],"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/rmariuzzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-14T13:50:31.000Z","updated_at":"2025-02-11T21:33:12.000Z","dependencies_parsed_at":"2022-08-13T19:20:35.335Z","dependency_job_id":null,"html_url":"https://github.com/rmariuzzo/laravel-localization-loader","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Flaravel-localization-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Flaravel-localization-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Flaravel-localization-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Flaravel-localization-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmariuzzo","download_url":"https://codeload.github.com/rmariuzzo/laravel-localization-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814898,"owners_count":20352037,"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":["laravel-localization","webpack-loader"],"created_at":"2024-10-10T07:10:42.494Z","updated_at":"2025-03-16T10:31:52.459Z","avatar_url":"https://github.com/rmariuzzo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Laravel localization Loader – Laravel localization Loader for Webpack. Convert Laravel Translation files (php or json) to JavaScript Objects.](banner.svg)\n\n\n## Features\n\n - Support both Laravel PHP and JSON translation files.\n - 100% test coverage.\n - Only has two dependencies: [json-loader](https://github.com/webpack-contrib/json-loader) and [php-array-loader](https://github.com/rmariuzzo/php-array-loader).\n\n## Installation\n\n```shell\nnpm install laravel-localization-loader --save-dev\n```\n\nor\n\n```shell\nyarn add laravel-localization-loader --dev\n```\n\n## Configuration\n\n### Webpack 2+\n\n```js\n// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        // Matches all PHP or JSON files in `resources/lang` directory.\n        test: /resources[\\\\\\/]lang.+\\.(php|json)$/,\n        loader: 'laravel-localization-loader',\n      }\n    ]\n  }\n}\n```\n\n### Laravel Mix\n\n```js\n// webpack.mix.js\nmix.webpackConfig({\n  module: {\n    rules: [\n      {\n        // Matches all PHP or JSON files in `resources/lang` directory.\n        test: /resources[\\\\\\/]lang.+\\.(php|json)$/,\n        loader: 'laravel-localization-loader',\n      }\n    ]\n  }\n});\n```\n\n## Usage\n\n### Lang.js\n\nFirst, you will need to install [Lang.js](https://github.com/rmariuzzo/Lang.js) then you may want to create a `messages.js` files that look as follow:\n\n```js\n// messages.js\nexport default {\n  // The key format should be: 'locale.filename'.\n  'en.messages': require('../../resources/lang/en/messages.php'),\n  'es.messages': require('../../resources/lang/es/messages.php'),\n  'en.auth': require('../../resources/lang/en/auth.php'),\n  'es.auth': require('../../resources/lang/es/auth.php'),\n}\n```\n\nThen somewhere else in your awesome app:\n\n```js\n// page.js\nimport Lang from 'lang.js'\nimport messages from './messages'\n\nconst lang = new Lang({ messages })\nlang.get('messages.hello')\n```\n\nProfit!\n\n## Development\n\n  1. Clone and fork this repo.\n  2. Install dependencies: yarn or npm install.\n  3. [Run tests](#test).\n  4. Prepare a pull request.\n\n### Test\n\n  - `yarn test` – to run all tests.\n  - `yarn test -- --watch` – to run all tests in watch mode.\n\n#### Coverage\n\n  - `yarn test -- --coverage` – to run all tests with coverage.\n  - `yarn test -- --coverage --watch` – to run all tests with coverage in watch mode.\n\n### Publish\n\n  1. Bump package version: `yarn version --new-version x.x.x -m 'Version %s.'`.\n  2. Publish to NPM registry: `npm publish`.\n  3. Push new tag: `git push origin --tags`.\n\n\u003cdiv align=center\u003e\n\nMade with :heart: by [Rubens Mariuzzo](https://github.com/rmariuzzo).\n\n[MIT license](LICENSE)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmariuzzo%2Flaravel-localization-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmariuzzo%2Flaravel-localization-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmariuzzo%2Flaravel-localization-loader/lists"}