Skip to content

Commit 15c9528

Browse files
committed
review comments
1 parent 67d1a97 commit 15c9528

File tree

4 files changed

+7
-23
lines changed

4 files changed

+7
-23
lines changed

README.md

-10
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ npm install --save @polymer/app-localize-behavior
2323
```html
2424
<html>
2525
<head>
26-
<!-- You MUST import this library first for the behaviour to work -->
27-
<script src="../node_modules/intl-messageformat/dist/intl-messageformat.js"></script>
28-
2926
<!-- Optional: Intl polyfill -->
3027
<script src="https://unpkg.com/[email protected]/dist/Intl.min.js"></script>
3128
<script src="https://unpkg.com/[email protected]/locale-data/jsonp/en.js"></script>
@@ -65,14 +62,7 @@ class SampleElement extends mixinBehaviors([AppLocalizeBehavior], PolymerElement
6562
}
6663
customElements.define('sample-element', SampleElement);
6764
```
68-
## Changes in 3.0
69-
If you've used this element in previous versions, the only notable change is that now
70-
you **must** include the `IntlMessageFormat` library yourself -- this is because
71-
it is an older library that was not written in a module-friendly way, and cannot
72-
be used inside of a ES module (since it uses the `this` object, which is
73-
not defined).
7465

75-
This is shown both in the code snippet above, and the [demo](https://github.com/PolymerElements/app-localize-behavior/blob/master/demo/index.html).
7666
## Contributing
7767
If you want to send a PR to this element, here are
7868
the instructions for running the tests and demo locally:

app-localize-behavior.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ found at http://polymer.github.io/PATENTS.txt
1010
*/
1111
import '@polymer/polymer/polymer-legacy.js';
1212
import '@polymer/iron-ajax/iron-ajax.js';
13+
import IntlMessageFormat from 'intl-messageformat/src/main.js';
14+
window.IntlMessageFormat = IntlMessageFormat;
1315

1416
// This isn't a complete `Object.assign` polyfill, but this element expects
1517
// JSON and doesn't provide more than one source object.
@@ -25,14 +27,14 @@ var assign =
2527
};
2628

2729
/**
28-
`Polymer.AppLocalizeBehavior` wraps the [format.js](http://formatjs.io/)
30+
`AppLocalizeBehavior` wraps the [format.js](http://formatjs.io/)
2931
library to help you internationalize your application. Note that if you're on
3032
a browser that does not natively support the
3133
[Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl)
3234
object, you must load the polyfill yourself. An example polyfill can
3335
be found [here](https://github.com/andyearnshaw/Intl.js/).
3436
35-
`Polymer.AppLocalizeBehavior` supports the same
37+
`AppLocalizeBehavior` supports the same
3638
[message-syntax](http://formatjs.io/guides/message-syntax/) of format.js, in
3739
its entirety; use the library docs as reference for the available message
3840
formats and options.
@@ -42,7 +44,7 @@ var assign =
4244
import {PolymerElement, html} from '@polymer/polymer';
4345
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';
4446
import {AppLocalizeBehavior} from
45-
'@polymer/app-localize-behavior/app-localize-behavior.js';
47+
'@polymer/app-localize-behavior/app-localize-behavior.js';
4648
4749
class SampleElement extends extends mixinBehaviors(
4850
[AppLocalizeBehavior], PolymerElement) {
@@ -98,7 +100,7 @@ var assign =
98100
import {PolymerElement, html} from '@polymer/polymer';
99101
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';
100102
import {AppLocalizeBehavior} from
101-
'@polymer/app-localize-behavior/app-localize-behavior.js';
103+
'@polymer/app-localize-behavior/app-localize-behavior.js';
102104
103105
class SampleElement extends extends mixinBehaviors(
104106
[AppLocalizeBehavior], PolymerElement) {
@@ -128,7 +130,7 @@ var assign =
128130
customElements.define('sample-element', SampleElement);
129131
130132
@demo demo/index.html
131-
@polymerBehavior Polymer.AppLocalizeBehavior
133+
@polymerBehavior AppLocalizeBehavior
132134
*/
133135
export const AppLocalizeBehavior = {
134136
/**
@@ -144,13 +146,11 @@ export const AppLocalizeBehavior = {
144146

145147
/**
146148
Fired after the resources have been loaded.
147-
*
148149
@event app-localize-resources-loaded
149150
*/
150151

151152
/**
152153
Fired when the resources cannot be loaded due to an error.
153-
*
154154
@event app-localize-resources-error
155155
*/
156156

demo/index.html

-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818

1919
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@^2.0.0/webcomponents-loader.js"></script>
2020

21-
<!-- You need to import this library first for the behaviour to work -->
22-
<script src="../node_modules/intl-messageformat/dist/intl-messageformat.js"></script>
23-
2421
<!-- Optional: Intl polyfill -->
2522
<script src="https://unpkg.com/[email protected]/dist/Intl.min.js"></script>
2623
<script src="https://unpkg.com/[email protected]/locale-data/jsonp/en.js"></script>

test/basic.html

-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
2121
<script src="../node_modules/wct-browser-legacy/browser.js"></script>
2222

23-
<!-- You need to import this library first for the behaviour to work -->
24-
<script src="../node_modules/intl-messageformat/dist/intl-messageformat.js"></script>
25-
2623
<!-- Intl polyfill -->
2724
<script src="../node_modules/intl/dist/Intl.min.js"></script>
2825
<script src="../node_modules/intl/locale-data/jsonp/en.js"></script>

0 commit comments

Comments
 (0)