app-localize-behavior

WebJar for app-localize-behavior

License

License

BSD 3-Clause
GroupId

GroupId

org.webjars.bowergithub.polymerelements
ArtifactId

ArtifactId

app-localize-behavior
Last Version

Last Version

2.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

app-localize-behavior
WebJar for app-localize-behavior
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/PolymerElements/app-localize-behavior

Download app-localize-behavior

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bowergithub.polymerelements/app-localize-behavior/ -->
<dependency>
    <groupId>org.webjars.bowergithub.polymerelements</groupId>
    <artifactId>app-localize-behavior</artifactId>
    <version>2.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bowergithub.polymerelements/app-localize-behavior/
implementation 'org.webjars.bowergithub.polymerelements:app-localize-behavior:2.0.2'
// https://jarcasting.com/artifacts/org.webjars.bowergithub.polymerelements/app-localize-behavior/
implementation ("org.webjars.bowergithub.polymerelements:app-localize-behavior:2.0.2")
'org.webjars.bowergithub.polymerelements:app-localize-behavior:jar:2.0.2'
<dependency org="org.webjars.bowergithub.polymerelements" name="app-localize-behavior" rev="2.0.2">
  <artifact name="app-localize-behavior" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bowergithub.polymerelements', module='app-localize-behavior', version='2.0.2')
)
libraryDependencies += "org.webjars.bowergithub.polymerelements" % "app-localize-behavior" % "2.0.2"
[org.webjars.bowergithub.polymerelements/app-localize-behavior "2.0.2"]

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.bowergithub.polymerelements : iron-ajax jar [1.0.0,3)
org.webjars.bowergithub.yahoo : intl-messageformat jar [1.0.0,2)
org.webjars.bowergithub.polymer : polymer jar [1.9.0,3)

Project Modules

There are no modules declared in this project.

Published on NPM Build status Published on webcomponents.org

<app-localize-behavior>

app-localize-behavior is a behavior that wraps the format.js library to help you internationalize your application. Note that if you're on a browser that does not natively support the Intl object, you must load the polyfill yourself. An example polyfill can be found here.

See: Documentation, Demo.

Usage

Installation

npm install --save @polymer/app-localize-behavior

In an html file using the localized element

<html>
  <head>
    <!-- Optional: Intl polyfill -->
    <script src="https://unpkg.com/[email protected]/dist/Intl.min.js"></script>
    <script src="https://unpkg.com/[email protected]/locale-data/jsonp/en.js"></script>
    <script src="https://unpkg.com/[email protected]/locale-data/jsonp/fr.js"></script>

    <!-- Elements using the behaviour -->
    <script type="module" src="sample-element.js"></script>
  </head>
  <body>
    <sample-element></sample-element>
  </body>
</html>

Localizing a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer';
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';
import {AppLocalizeBehavior} from '@polymer/app-localize-behavior/app-localize-behavior.js';

class SampleElement extends mixinBehaviors([AppLocalizeBehavior], PolymerElement) {
  static get template() {
    return html`
      <div>{{localize('hello', 'name', 'Batman')}}</div>
    `;
  }

  static get properties() {
    return {
      language: { value: 'en' },
    }
  }

  function attached() {
    this.loadResources(this.resolveUrl('locales.json'));
  }
}
customElements.define('sample-element', SampleElement);

Contributing

If you want to send a PR to this element, here are the instructions for running the tests and demo locally:

Installation

git clone https://github.com/PolymerElements/app-localize-behavior
cd app-localize-behavior
npm install
npm install -g polymer-cli

Running the demo locally

polymer serve --npm
open http://127.0.0.1:<port>/demo/

Running the tests

polymer test --npm
org.webjars.bowergithub.polymerelements

Versions

Version
2.0.2
2.0.1
2.0.0
0.10.2