app-localize-behavior
Polymer behaviour to help internationalize your application
<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/intl@1.2.5/dist/Intl.min.js"></script>
<script src="https://unpkg.com/intl@1.2.5/locale-data/jsonp/en.js"></script>
<script src="https://unpkg.com/intl@1.2.5/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
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Dependencies
- @polymer/iron-ajax#^3.0.0-pre.26
- @polymer/polymer#^3.0.0
- intl-messageformat#^2.2.0
- Released
- 2018-09-13
- Maturity
- IMPORTED
- License
- BSD 3-clause "New" or "Revised" License
Compatibility
- Framework
- Polymer 1.0+
- Polymer 3.0+
- Polymer 2.0+ in 2.0.2
- Browser
- Browser Independent
app-localize-behavior - Vaadin Add-on Directory
Polymer behaviour to help internationalize your applicationDocumentation
View on NPM
View on GitHub
GitHub Homepage
Issue tracker
License
app-localize-behavior version 0.1.0
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 0.2.0
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 0.9.0
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 0.9.1
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 0.9.2
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 0.10.0
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 0.10.1
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 0.10.2
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 1.0.0
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 1.0.1
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 1.0.2
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#^1.0.0
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#^1.3.0
app-localize-behavior version 2.0.0
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#1 - 2
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#1.9 - 2
app-localize-behavior version 3.0.0-pre.2
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.1
* @polymer/polymer#^3.0.0-pre.1
app-localize-behavior version 3.0.0-pre.4
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.4
* @polymer/polymer#^3.0.0-pre.4
app-localize-behavior version 3.0.0-pre.6
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.6
* @polymer/polymer#^3.0.0-pre.6
app-localize-behavior version 3.0.0-pre.7
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.7
* @polymer/polymer#^3.0.0-pre.7
app-localize-behavior version 2.0.1
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#1 - 2
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#1.9 - 2
app-localize-behavior version 3.0.0-pre.8
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.7
* @polymer/polymer#^3.0.0-pre.7
app-localize-behavior version 3.0.0-pre.10
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.10
* @polymer/polymer#^3.0.0-pre.10
app-localize-behavior version 3.0.0-pre.11
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.10
* @polymer/polymer#^3.0.0-pre.10
app-localize-behavior version 3.0.0-pre.12
### Dependencies
* @polymer/iron-ajax#3.0.0-pre.12
* @polymer/polymer#3.0.0-pre.12
app-localize-behavior version 3.0.0-pre.13
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.13
* intl-messageformat#^2.2.0
* @polymer/polymer#^3.0.0-pre.13
app-localize-behavior version 3.0.0-pre.14
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.14
* intl-messageformat#^2.2.0
* @polymer/polymer#^3.0.0-pre.13
app-localize-behavior version 3.0.0-pre.15
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.15
* intl-messageformat#^2.2.0
* @polymer/polymer#^3.0.0-pre.13
app-localize-behavior version 3.0.0-pre.16
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.16
* intl-messageformat#^2.2.0
* @polymer/polymer#^3.0.0-pre.13
app-localize-behavior version 3.0.0-pre.17
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.17
* intl-messageformat#^2.2.0
* @polymer/polymer#^3.0.0-pre.13
app-localize-behavior version 3.0.0-pre.18
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.18
* intl-messageformat#^2.2.0
* @polymer/polymer#^3.0.0
app-localize-behavior version 3.0.0-pre.19
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.19
* intl-messageformat#^2.2.0
* @polymer/polymer#^3.0.0
app-localize-behavior version 2.0.2
### Dependencies
* iron-ajax#PolymerElements/iron-ajax#1 - 2
* intl-messageformat#yahoo/intl-messageformat#^1.0.0
* polymer#Polymer/polymer#1.9 - 2
app-localize-behavior version 3.0.0-pre.20
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.20
* intl-messageformat#^2.2.0
* @polymer/polymer#^3.0.0
app-localize-behavior version 3.0.0-pre.21
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.21
* intl-messageformat#^2.2.0
* @polymer/polymer#^3.0.0
app-localize-behavior version 3.0.0-pre.22
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.20
* @polymer/polymer#^3.0.0
* intl-messageformat#^2.2.0
app-localize-behavior version 3.0.0-pre.23
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.22
* @polymer/polymer#^3.0.0
* intl-messageformat#^2.2.0
app-localize-behavior version 3.0.0-pre.24
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.22
* @polymer/polymer#^3.0.0
* intl-messageformat#^2.2.0
app-localize-behavior version 3.0.0-pre.25
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.24
* @polymer/polymer#^3.0.0
* intl-messageformat#^2.2.0
app-localize-behavior version 3.0.0-pre.26
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.25
* @polymer/polymer#^3.0.0
* intl-messageformat#^2.2.0
app-localize-behavior version 3.0.0
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.26
* @polymer/polymer#^3.0.0
* intl-messageformat#^2.2.0
app-localize-behavior version 3.0.1
### Dependencies
* @polymer/iron-ajax#^3.0.0-pre.26
* @polymer/polymer#^3.0.0
* intl-messageformat#^2.2.0