{"id":21374549,"url":"https://github.com/brightspaceui/localize-behavior","last_synced_at":"2026-02-26T03:58:36.754Z","repository":{"id":24974143,"uuid":"102643028","full_name":"BrightspaceUI/localize-behavior","owner":"BrightspaceUI","description":"Polymer mixins for localizing web components","archived":false,"fork":false,"pushed_at":"2025-06-23T18:19:40.000Z","size":149,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-07-09T11:24:26.183Z","etag":null,"topics":["localization","polymer","web-components"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BrightspaceUI.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-09-06T18:19:09.000Z","updated_at":"2025-06-23T18:19:43.000Z","dependencies_parsed_at":"2024-03-28T19:57:13.173Z","dependency_job_id":"06ca4e4a-8b09-44c8-98ad-3af659568042","html_url":"https://github.com/BrightspaceUI/localize-behavior","commit_stats":{"total_commits":78,"total_committers":8,"mean_commits":9.75,"dds":0.3205128205128205,"last_synced_commit":"ec63d847cf8d039852483595709079489e6e9fa8"},"previous_names":["brightspaceui/d2l-localize-behavior"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/BrightspaceUI/localize-behavior","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrightspaceUI%2Flocalize-behavior","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrightspaceUI%2Flocalize-behavior/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrightspaceUI%2Flocalize-behavior/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrightspaceUI%2Flocalize-behavior/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BrightspaceUI","download_url":"https://codeload.github.com/BrightspaceUI/localize-behavior/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrightspaceUI%2Flocalize-behavior/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265120131,"owners_count":23714488,"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":["localization","polymer","web-components"],"created_at":"2024-11-22T08:43:39.540Z","updated_at":"2026-01-11T13:31:37.305Z","avatar_url":"https://github.com/BrightspaceUI.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e Building Lit components? Use [BrightspaceUI/core](https://github.com/BrightspaceUI/core) instead.\n\n# @brightspace-ui/localize-behavior\n\n[Polymer](https://www.polymer-project.org) mixin for localization of text, dates, times, numbers and file sizes. Also supports automatic language resolution, timezone and locale overrides.\n\n## Installation\n\nInstall from NPM:\n\n```shell\nnpm install @brightspace-ui/localize-behavior\n```\n\n## Usage\n\n```javascript\nimport '@brightspace-ui/localize-behavior/d2l-localize-behavior.js';\nimport { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';\n\nclass MyElement extends mixinBehaviors([\n  D2L.PolymerBehaviors.LocalizeBehavior\n], PolymerElement) {\n\n  static get template() {\n    return html`\u003cp\u003e[[localize('hello')]]\u003c/p\u003e`;\n  }\n\n  localizeConfig: {\n    importFunc: async lang =\u003e (await import(`./lang/${lang}.js`)).default\n  }\n}\n```\n\n### Language Resources\n\nStore localization resources in their own directory with nothing else in it. There should be one JavaScript file for each supported locale.\n\n```javascript\n// lang/en.js\nexport default {\n  hello: `Hello, {firstName}!`\n};\n```\n```javascript\n// lang/fr.js\nexport default {\n  hello: `Bonjour, {firstName}!`\n};\n```\n\n* Always provide files for base languages (e.g. \"en\", \"fr\", \"pt\") so that if the user is using an unsupported regional language (e.g. \"en-au\", \"fr-ca\", \"pt-br\") it can fall back to the base language.\n* If there's no entry for a particular language, and no base language, the value of `data-lang-default` on the `\u003chtml\u003e` element will be used.\n* If no `data-lang-default` is specified, \"en\" will be used as a last resort.\n\n### `localize()`\n\nThe `localize()` method is used to localize a piece of text in the component's `template`.\n\nIf the localized string contains arguments, pass them as additional parameters to `localize`:\n\n```javascript\nstatic get template() {\n  return html`\u003cp\u003e[[localize('hello', 'firstName', 'Mary')]]\u003c/p\u003e`;\n}\n```\n\n### Numbers, File Sizes, Dates and Times\n\nWhile `localize-behavior` does support formatting and parsing numbers, dates and times, instead please use the [https://github.com/BrightspaceUI/intl/](BrightspaceUI/intl) library directly.\n\n## Developing\n\nAfter cloning the repo, run `npm install` to install dependencies.\n\n### Running the demos\n\nTo start a [@web/dev-server](https://modern-web.dev/docs/dev-server/overview/) that hosts the demo page and tests:\n\n```shell\nnpm start\n```\n\n### Testing\n\nTo run the full suite of tests:\n\n```shell\nnpm test\n```\n\nAlternatively, tests can be selectively run:\n\n```shell\n# eslint\nnpm run lint:eslint\n\n# unit tests\nnpm run test:unit\n```\n\n### Versioning and Releasing\n\nThis repo is configured to use `semantic-release`. Commits prefixed with `fix:` and `feat:` will trigger patch and minor releases when merged to `main`.\n\nTo learn how to create major releases and release from maintenance branches, refer to the [semantic-release GitHub Action](https://github.com/BrightspaceUI/actions/tree/main/semantic-release) documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightspaceui%2Flocalize-behavior","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrightspaceui%2Flocalize-behavior","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightspaceui%2Flocalize-behavior/lists"}