# dr-niels-app-localize-behavior

> A behavior to help with internationalizating apps

Latest version **3.0.0** (published 2020-10-02) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install dr-niels-app-localize-behavior
pnpm add dr-niels-app-localize-behavior
yarn add dr-niels-app-localize-behavior
bun add dr-niels-app-localize-behavior
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2020-10-02 |
| First published | 2018-06-06 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 66 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 48 |
| Author | The Polymer Authors |
| Maintainers | nthole |
| Keywords | web-components, polymer, i18n, translation, localization |

## Links

- npm: https://www.npmjs.com/package/dr-niels-app-localize-behavior
- Repository: https://github.com/polymerelements/app-localize-behavior
- Issues: https://github.com/polymerelements/app-localize-behavior/issues
- npm.io page: https://npm.io/package/dr-niels-app-localize-behavior

## Dependencies (3)

- [@polymer/polymer](https://npm.io/package/@polymer/polymer.md) ^3.0.0
- [@polymer/iron-ajax](https://npm.io/package/@polymer/iron-ajax.md) ^3.0.0-pre.19
- [dr-niels-intl-messageformat](https://npm.io/package/dr-niels-intl-messageformat.md) ^2.2.0

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2020-10-02
- 3.0.0-pre.19 — 2018-06-06

## README

This is a Polymer 3 conversion of the app-localize-behavior element from Collaborne (https://github.com/PolymerElements/app-localize-behavior) with some minor adjustments. The readme was not updated and is still the one from the original app-localize-behavior element! Nowadays, the original element was already updated to Polymer 3, so it's probably better to use the original element and not this one.

<!---

This README is automatically generated from the comments in these files:
app-localize-behavior.html

Edit those files, and our readme bot will duplicate them over here!
Edit this file, and the bot will squash your changes :)

The bot does some handling of markdown. Please file a bug if it does the wrong
thing! https://github.com/PolymerLabs/tedium/issues

-->

[![Build status](https://travis-ci.org/PolymerElements/app-localize-behavior.svg?branch=master)](https://travis-ci.org/PolymerElements/app-localize-behavior)


## Polymer.AppLocalizeBehavior

`Polymer.AppLocalizeBehavior` wraps the [format.js](http://formatjs.io/) library to
help you internationalize your application. Note that if you're on a browser that
does not natively support the [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl)
object, you must load the polyfill yourself. An example polyfill can
be found [here](https://github.com/andyearnshaw/Intl.js/).

`Polymer.AppLocalizeBehavior` supports the same [message-syntax](http://formatjs.io/guides/message-syntax/)
of format.js, in its entirety; use the library docs as reference for the
available message formats and options.

Sample application loading resources from an external file:

```html
<dom-module id="x-app">
   <template>
    <div>{{localize('hello', 'name', 'Batman')}}</div>
   </template>
   <script>
      Polymer({
        is: "x-app",

        behaviors: [
          Polymer.AppLocalizeBehavior
        ],

        properties: {
          language: {
            value: 'en'
          },
        }

        attached: function() {
          this.loadResources(this.resolveUrl('locales.json'));
        },
      });
   &lt;/script>
</dom-module>
```

Alternatively, you can also inline your resources inside the app itself:

```html
<dom-module id="x-app">
   <template>
    <div>{{localize('hello', 'name', 'Batman')}}</div>
   </template>
   <script>
      Polymer({
        is: "x-app",

        behaviors: [
          Polymer.AppLocalizeBehavior
        ],

        properties: {
          language: {
            value: 'en'
          },
          resources: {
            value: function() {
              return {
                'en': { 'hello': 'My name is {name}.' },
                'fr': { 'hello': 'Je m\'apelle {name}.' }
              }
          }
        }
      });
   &lt;/script>
</dom-module>
```

---
_Source: https://npm.io/package/dr-niels-app-localize-behavior · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
