{"id":15152707,"url":"https://github.com/messageformat/yaml-loader","last_synced_at":"2025-09-29T23:32:03.125Z","repository":{"id":41190329,"uuid":"111288673","full_name":"messageformat/yaml-loader","owner":"messageformat","description":"Deprecated; use messageformat-loader instead","archived":true,"fork":false,"pushed_at":"2018-07-20T06:24:10.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":73,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-17T04:32:28.997Z","etag":null,"topics":["messageformat","webpack","yaml"],"latest_commit_sha":null,"homepage":"https://github.com/messageformat/messageformat/tree/master/packages/loader","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/messageformat.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":"2017-11-19T11:26:48.000Z","updated_at":"2023-01-28T18:54:02.000Z","dependencies_parsed_at":"2022-08-30T18:22:02.577Z","dependency_job_id":null,"html_url":"https://github.com/messageformat/yaml-loader","commit_stats":null,"previous_names":["eemeli/messageformat-yaml-loader"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/messageformat%2Fyaml-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/messageformat%2Fyaml-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/messageformat%2Fyaml-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/messageformat%2Fyaml-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/messageformat","download_url":"https://codeload.github.com/messageformat/yaml-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234673608,"owners_count":18869698,"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":["messageformat","webpack","yaml"],"created_at":"2024-09-26T16:21:29.701Z","updated_at":"2025-09-29T23:31:57.830Z","avatar_url":"https://github.com/messageformat.png","language":"JavaScript","readme":"# YAML i18n loader for Webpack\n\nLoads YAML files into JavaScript as precompiled functions using\n[yaml-to-messageformat] and [messageformat].\n\nWith the default options, will load [Rails i18n] YAML files, but can be\nconfigured for other contents as well. E.g. for YAML with contents already in\nICU MessageFormat, use with options `{ pluralVariable: null, replacements: [] }`.\n\nBy default, variables of the form `%{foo}` and `%b` will be detected in the\ninput strings, and an object with keys matching the pluralisation classes of the\ncurrent language (set by having a parent key such as `en` or `fi`) will be\nhandled as a proper plural.\n\n## Installation\n\n```sh\nnpm install messageformat-yaml-loader\n```\nor\n```sh\nyarn add messageformat-yaml-loader\n```\n\n\n## Usage\n\nFor a working demo of the following, run `npm install` in the\n[`example/`](./example/) directory, and then open `example/dist/index.html` in\na browser.\n\n\n#### Webpack configuration\n\n```js\n{\n  test: [/\\.yaml$/, /\\.yml$/],\n  loader: require.resolve('messageformat-yaml-loader'),\n  options: {\n    biDiSupport: false,\n    defaultLocale: 'en',\n    includeLocales: null,\n    pluralVariable: 'count',\n    verbose: false\n  }\n}\n```\n\nSome of the default option values are shown, but none is required. Most options\nare passed on to [yaml-to-messageformat] (see there for their documentation);\n`biDiSupport` enables bi-directional text support in [messageformat].\n\n\n#### messages.yml\n\n```yaml\nen:\n  errors:\n    format: \"%{attribute} %{message}\"\n    messages:\n      confirmation: \"doesn't match %{attribute}\"\n      accepted: \"must be accepted\"\n      wrong_length:\n        one: \"is the wrong length (should be 1 character)\"\n        other: \"is the wrong length (should be %{count} characters)\"\n      equal_to: \"must be equal to %{count}\"\n```\n\n\n#### example.js\n\n```js\nimport messages from './messages.yml'\nconst { format, messages: errors } = messages.en.errors\n\nerrors.accepted()\n// 'must be accepted'\n\nformat({\n  attribute: 'Your message',\n  message: errors.wrong_length({ count: 42 })\n})\n// 'Your message is the wrong length (should be 42 characters)'\n```\n\n\n[messageformat]: https://messageformat.github.io/\n[Rails i18n]: http://guides.rubyonrails.org/i18n.html\n[yaml-to-messageformat]: https://github.com/eemeli/yaml-to-messageformat\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmessageformat%2Fyaml-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmessageformat%2Fyaml-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmessageformat%2Fyaml-loader/lists"}