{"id":13748608,"url":"https://github.com/PolymerElements/app-localize-behavior","last_synced_at":"2025-05-09T11:31:01.562Z","repository":{"id":57132126,"uuid":"55096855","full_name":"PolymerElements/app-localize-behavior","owner":"PolymerElements","description":"Polymer behaviour to help internationalize your application","archived":false,"fork":false,"pushed_at":"2023-10-16T14:02:53.000Z","size":229,"stargazers_count":48,"open_issues_count":32,"forks_count":55,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-18T13:07:19.258Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PolymerElements.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-03-30T20:51:09.000Z","updated_at":"2022-09-19T17:23:28.000Z","dependencies_parsed_at":"2024-01-15T00:53:58.163Z","dependency_job_id":"a6ef1304-d195-441a-ba18-876354b81511","html_url":"https://github.com/PolymerElements/app-localize-behavior","commit_stats":{"total_commits":129,"total_committers":21,"mean_commits":6.142857142857143,"dds":0.7364341085271318,"last_synced_commit":"e796bfa6876498608ab2d0d63c89bffece80c0da"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerElements%2Fapp-localize-behavior","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerElements%2Fapp-localize-behavior/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerElements%2Fapp-localize-behavior/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerElements%2Fapp-localize-behavior/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PolymerElements","download_url":"https://codeload.github.com/PolymerElements/app-localize-behavior/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253240350,"owners_count":21876593,"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-08-03T07:00:45.572Z","updated_at":"2025-05-09T11:31:01.283Z","avatar_url":"https://github.com/PolymerElements.png","language":"HTML","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"[![Published on NPM](https://img.shields.io/npm/v/@polymer/app-localize-behavior.svg)](https://www.npmjs.com/package/@polymer/app-localize-behavior)\n[![Build status](https://travis-ci.org/PolymerElements/app-localize-behavior.svg?branch=master)](https://travis-ci.org/PolymerElements/app-localize-behavior)\n[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://webcomponents.org/element/@polymer/app-localize-behavior)\n\n## \u0026lt;app-localize-behavior\u0026gt;\n`app-localize-behavior` is a behavior that wraps the [format.js](http://formatjs.io/) library to\nhelp you internationalize your application. Note that if you're on a browser that\ndoes not natively support the [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl)\nobject, you must load the polyfill yourself. An example polyfill can\nbe found [here](https://github.com/andyearnshaw/Intl.js/).\n\nSee: [Documentation](https://www.webcomponents.org/element/@polymer/app-localize-behavior),\n  [Demo](https://www.webcomponents.org/element/@polymer/app-localize-behavior/demo/demo/index.html).\n\n## Usage\n\n### Installation\n```\nnpm install --save @polymer/app-localize-behavior\n```\n\n### In an html file using the localized element\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003c!-- Optional: Intl polyfill --\u003e\n    \u003cscript src=\"https://unpkg.com/intl@1.2.5/dist/Intl.min.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"https://unpkg.com/intl@1.2.5/locale-data/jsonp/en.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"https://unpkg.com/intl@1.2.5/locale-data/jsonp/fr.js\"\u003e\u003c/script\u003e\n\n    \u003c!-- Elements using the behaviour --\u003e\n    \u003cscript type=\"module\" src=\"sample-element.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003csample-element\u003e\u003c/sample-element\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Localizing a Polymer 3 element\n```js\nimport {PolymerElement, html} from '@polymer/polymer';\nimport {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';\nimport {AppLocalizeBehavior} from '@polymer/app-localize-behavior/app-localize-behavior.js';\n\nclass SampleElement extends mixinBehaviors([AppLocalizeBehavior], PolymerElement) {\n  static get template() {\n    return html`\n      \u003cdiv\u003e{{localize('hello', 'name', 'Batman')}}\u003c/div\u003e\n    `;\n  }\n\n  static get properties() {\n    return {\n      language: { value: 'en' },\n    }\n  }\n\n  function attached() {\n    this.loadResources(this.resolveUrl('locales.json'));\n  }\n}\ncustomElements.define('sample-element', SampleElement);\n```\n\n## Contributing\nIf you want to send a PR to this element, here are\nthe instructions for running the tests and demo locally:\n\n### Installation\n```sh\ngit clone https://github.com/PolymerElements/app-localize-behavior\ncd app-localize-behavior\nnpm install\nnpm install -g polymer-cli\n```\n\n### Running the demo locally\n```sh\npolymer serve --npm\nopen http://127.0.0.1:\u003cport\u003e/demo/\n```\n\n### Running the tests\n```sh\npolymer test --npm\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPolymerElements%2Fapp-localize-behavior","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPolymerElements%2Fapp-localize-behavior","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPolymerElements%2Fapp-localize-behavior/lists"}