i18n-behavior
Version:
Instant and Modular I18N engine for lit-html and Polymer
1,543 lines • 95.5 kB
JSON
{
"schema_version": "1.0.0",
"elements": [
{
"description": "",
"summary": "",
"path": "i18n-preference.js",
"properties": [
{
"name": "persist",
"type": "boolean | null | undefined",
"description": "Persistence of preference",
"privacy": "public",
"sourceRange": {
"start": {
"line": 57,
"column": 4
},
"end": {
"line": 63,
"column": 5
}
},
"metadata": {
"polymer": {
"notify": true,
"observer": "\"_onPersistChange\"",
"attributeType": "Boolean"
}
},
"defaultValue": "false"
},
{
"name": "importMeta",
"type": "?",
"description": "",
"privacy": "public",
"sourceRange": {
"start": {
"line": 50,
"column": 2
},
"end": {
"line": 50,
"column": 25
}
},
"metadata": {
"polymer": {
"readOnly": false
}
}
}
],
"methods": [
{
"name": "ready",
"description": "Ready callback to initialize this.lang",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 69,
"column": 2
},
"end": {
"line": 77,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
},
{
"name": "attached",
"description": "Attached callback to initialize html.lang and its observation",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 82,
"column": 2
},
"end": {
"line": 92,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
},
{
"name": "detached",
"description": "Detached callback to diconnect html.lang observation",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 97,
"column": 2
},
"end": {
"line": 99,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
},
{
"name": "_onLoadEmptyStorage",
"description": "Initialize an empty localstorage",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 104,
"column": 2
},
"end": {
"line": 128,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
},
{
"name": "_onLoadStorage",
"description": "Handle the loaded storage value",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 133,
"column": 2
},
"end": {
"line": 154,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
},
{
"name": "_onPersistChange",
"description": "Handle persist changes",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 161,
"column": 2
},
"end": {
"line": 174,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "value",
"type": "Boolean",
"description": "new this.persist value"
}
],
"return": {
"type": "void"
}
},
{
"name": "_onStorageValueChange",
"description": "Handle storage value changes",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 181,
"column": 2
},
"end": {
"line": 203,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "e",
"type": "Event",
"description": "value-changed event on the storage"
}
],
"return": {
"type": "void"
}
},
{
"name": "_htmlLangMutationObserverCallback",
"description": "Handle value changes on localstorage",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 213,
"column": 2
},
"end": {
"line": 227,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "mutations",
"type": "Array.<MutationRecord>",
"description": "Array of MutationRecords for html.lang\n\nNote:\n - Bound to this element"
}
],
"return": {
"type": "void"
}
},
{
"name": "_observe",
"description": "Set up html.lang mutation observer",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 232,
"column": 2
},
"end": {
"line": 241,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
},
{
"name": "_disconnect",
"description": "Disconnect html.lang mutation observer",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 246,
"column": 2
},
"end": {
"line": 250,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
}
],
"staticMethods": [],
"demos": [],
"metadata": {},
"sourceRange": {
"start": {
"line": 49,
"column": 8
},
"end": {
"line": 251,
"column": 1
}
},
"privacy": "public",
"superclass": "HTMLElement",
"attributes": [
{
"name": "persist",
"description": "Persistence of preference",
"sourceRange": {
"start": {
"line": 57,
"column": 4
},
"end": {
"line": 63,
"column": 5
}
},
"metadata": {},
"type": "boolean | null | undefined"
}
],
"events": [
{
"type": "CustomEvent",
"name": "persist-changed",
"description": "Fired when the `persist` property changes.",
"metadata": {}
}
],
"styling": {
"cssVariables": [],
"selectors": []
},
"slots": [],
"tagname": "i18n-preference"
},
{
"description": "`<i18n-attr-repo>` maintains a list of attributes targeted for UI localization. \nIt judges whether a specific attribute of an element requires localization or not. \n\n var attrRepository = \n document.createElement('i18n-attr-repo');\n\n attrRepository.registerLocalizableAttributes(\n 'custom-element',\n Polymer.DomModule.import('custom-element', 'template')\n );\n attrRepository.isLocalizableAttribute(inputElement, 'placeholder');\n\n### Interactions with `BehaviorsStore.I18nBehavior`\n\nThe element is not meant for DOM attachment. The object is\na singleton object dedicated for `BehaviorsStore.I18nBehavior`.\n`I18nBehavior` interacts with the localizable attributes repository in these 3 ways.\n\n### 1) Construct the repository for the standard elements from its own static template at the object creation.\n\n```\n // i18n-behavior.html\n var attrRepository = \n document.createElement('i18n-attr-repo');\n```\n\nPre-defined I18N-target attributes in the static template of `i18n-attr-repo`:\n\n```\n <dom-module id=\"i18n-attr-repo\">\n <template>\n <template id=\"standard\">\n <input placeholder>\n <any-elements title aria-label=\"$\" aria-valuetext=\"$\"></any-elements>\n\n <paper-input label error-message placeholder></paper-input>\n <paper-textarea label error-message placeholder></paper-textarea>\n <paper-dropdown-menu label></paper-dropdown-menu>\n <paper-toast text></paper-toast>\n <google-chart options cols rows data></google-chart>\n <google-signin label-signin label-signout label-additional></google-signin>\n <platinum-push-messaging title message></platinum-push-messaging>\n\n <json-data any-attributes></json-data>\n </template>\n </template>\n </dom-module>\n```\n\nThis static list is also referenced by [`gulp-i18n-preprocess`](https://github.com/t2ym/gulp-i18n-preprocess) filter for\nbuild-time automatic I18N of hard-coded string attributes.\n\n### 2) Register I18N-target attributes of custom elements from a template with id=\"custom\" in its light DOM.\n\nI18N-target attributes for custom elements without I18nBehavior can be registered to the respository by this method. \n\nExample I18N-target attributes in a static template in the light DOM of `i18n-attr-repo`:\n\n```\n <i18n-attr-repo>\n <template id=\"custom\">\n <shop-md-decorator error-message=\"$\"></shop-md-decorator>\n <input value=\"type=submit|button\">\n <my-element i18n-target-attr=\"attr=value,boolean-attr,!boolean-attr\"></my-element>\n <my-element i18n-target-attr=\"attr1=value1,attr2=value2,type-name\"></my-element>\n <my-element i18n-target-attr=\"boolean-attr=\"></my-element>\n <my-element i18n-target-attr=\"type-name2\"></my-element>\n </template>\n </i18n-attr-repo>\n```\n\nThis list is also referenced by [`gulp-i18n-preprocess`](https://github.com/t2ym/gulp-i18n-preprocess) filter for\nbuild-time automatic I18N of hard-coded string attributes.\n\nNote: Type name feature is currently ineffective and reserved for further expansion of the attribute I18N features.\n\n### 3) Register localizable attributes of the newly registered elements from the `text-attr` attribute of the element's template.\n\n```\n // i18n-behavior.html, scanning custom-element template\n var id = 'custom-element';\n attrRepository.registerLocalizableAttributes(\n id, \n Polymer.DomModule.import(id, 'template')\n );\n```\n```\n // custom-element.html\n <dom-module id=\"custom-element\">\n <template text-attr=\"localizable-attr1 localizable-attr2\">\n <span>{{localizableAttr1}}</span>\n <span>{{localizableAttr2}}</span>\n </template>\n <script>\n Polymer({\n is: 'custom-element',\n behaviors: [ BehaviorsStore.I18nBehavior ],\n properties: {\n localizableAttr1: {\n type: String\n },\n localizableAttr2: {\n type: String\n }\n }\n });\n </ script>\n </dom-module>\n```\n\n`text-attr` attributes are also traversed for build-time automatic I18N of \nhard-coded UI string attributes by [`gulp-i18n-preprocess`](https://github.com/t2ym/gulp-i18n-preprocess) filter.\n\n### 4) Judge localizability of attributes for the local DOM elements of the newly registered element.\n\n```\n // i18n-behavior.html, scanning custom-element-user template\n var element; // target element\n var attr;\n if (attrRepository.isLocalizableAttribute(element, attr.name)) {\n // make localizalbe-attr1 localizable\n }\n```\n```\n // custom-element-user.html\n <dom-module id=\"custom-element-user\">\n <template>\n <custom-element id=\"custom\"\n localizable-attr1=\"UI Text Label 1\"\n localizable-attr2=\"UI Text Label 2\">\n </custom-element>\n </template>\n <script>\n Polymer({\n is: 'custom-element-user',\n behaviors: [ BehaviorsStore.I18nBehavior ]\n });\n </ script>\n </dom-module>\n```\n```\n // template for custom-element-user after localization binding\n <template>\n <custom-element id=\"custom\"\n localizable-attr1=\"{{model.custom.localizable-attr1}}\"\n localizable-attr2=\"{{model.custom.localizable-attr2}}\">\n </custom-element>\n </template>\n```\n```\n // extracted localizable texts in custom-element-user element\n this.model = {\n \"custom\": {\n \"localizable-attr1\": \"UI Text Label 1\",\n \"localizable-attr2\": \"UI Text Label 2\"\n }\n }\n```\n\nSince dependent elements should be registered prior to a custom element being registered,\nthe repository can always maintain the complete list of localizable attributes for registered custom elements.\n\n- - -\n\n### Note\n\nThe described processes above are for debug builds with runtime localization traversal of templates\nby `I18nBehavior`.\n\nFor production builds, the build system can perform the same processes at build time so that \n`I18nBehavior` at clients can skip runtime traversal of templates.\n\n- - -\n\n### TODO\n\nHandle and judge JSON object attributes.",
"summary": "",
"path": "i18n-attr-repo.js",
"properties": [
{
"name": "importMeta",
"type": "?",
"description": "",
"privacy": "public",
"sourceRange": {
"start": {
"line": 228,
"column": 2
},
"end": {
"line": 228,
"column": 25
}
},
"metadata": {
"polymer": {
"readOnly": false
}
}
}
],
"methods": [
{
"name": "created",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 231,
"column": 2
},
"end": {
"line": 242,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
},
{
"name": "_created",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 244,
"column": 2
},
"end": {
"line": 260,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
},
{
"name": "isLocalizableAttribute",
"description": "Judge if a specific attribute of an element requires localization.",
"privacy": "public",
"sourceRange": {
"start": {
"line": 269,
"column": 2
},
"end": {
"line": 287,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "element",
"type": "HTMLElement",
"description": "Target element."
},
{
"name": "attr",
"type": "string",
"description": "Target attribute name."
}
]
},
{
"name": "_getType",
"description": "Get the type name or '$' for a specific attribute of an element from the attributes repository",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 296,
"column": 2
},
"end": {
"line": 323,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "element",
"type": "HTMLElement",
"description": "Target element."
},
{
"name": "value",
"type": "object",
"description": "this.data[tagName][attr]"
}
]
},
{
"name": "_matchAttribute",
"description": "Get the type name or '$' for a specific attribute of an element from the attributes repository\n\nFormat for selectors:\n - `attr=value` - Value of `attr` matches Regex `^value$`\n - `!boolean-attr` - Boolean attribute does not exist\n - `boolean-attr` - Boolean attribute exists with empty value\n - empty string `''` - Always matches",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 338,
"column": 2
},
"end": {
"line": 374,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "element",
"type": "HTMLElement",
"description": "Target element."
},
{
"name": "selector",
"type": "string",
"description": "Matching condition for target attribute."
}
],
"return": {
"type": "boolean",
"desc": "true - matching, false - not matching"
}
},
{
"name": "_compareSelectors",
"description": "Comparator for attribute selectors",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 383,
"column": 2
},
"end": {
"line": 387,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "s1",
"type": "string",
"description": "selector 1"
},
{
"name": "s2",
"type": "string",
"description": "selector 2"
}
],
"return": {
"type": "number",
"desc": "comparison result as -1, 0, or 1"
}
},
{
"name": "setLocalizableAttribute",
"description": "Add a new localizable attribute of an element to the repository.\n\nFormat for selector values for defining I18N-target attributes:\n - `attr1=value1,attr2=value2,boolean-attr,!boolean-attr` - Attribute value matching condition for property\n - `attr1=value1,attr2=value2,$` - Attribute value matching condition for attribute\n - `boolean-attr=` - Boolean attribute condition\n - `attr1=value1,type` - Attribute value condition with type name (type is currently ineffective)",
"privacy": "public",
"sourceRange": {
"start": {
"line": 402,
"column": 2
},
"end": {
"line": 439,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "element",
"type": "string",
"description": "Target element name."
},
{
"name": "attr",
"type": "string",
"description": "Target attribute name."
},
{
"name": "value",
"type": "?*",
"description": "Selector value"
}
],
"return": {
"type": "void"
}
},
{
"name": "registerLocalizableAttributes",
"description": "Pick up localizable attributes description for a custom element\nfrom `text-attr` attribute and register them to the repository.\nThe `text-attr` attribute is used in the template of a custom\nelement to declare localizable attributes of its own element.\n\nFormat:\n\n Type 1: `<template text-attr=\"localizable-attr1 attr2\">`\n\n Type 2: `<template text-attr localizable-attr1 attr2=\"value2\">`",
"privacy": "public",
"sourceRange": {
"start": {
"line": 456,
"column": 2
},
"end": {
"line": 490,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "element",
"type": "string",
"description": "Target element name."
},
{
"name": "template",
"type": "HTMLTemplateElement",
"description": "Template of the element."
}
],
"return": {
"type": "void"
}
},
{
"name": "_traverseTemplateTree",
"description": "Traverse the template of `i18n-attr-repo` in the ready() callback\nand construct the localizable attributes repository object. The method calls itself\nrecursively for traversal.",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 499,
"column": 2
},
"end": {
"line": 513,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "node",
"type": "HTMLElement",
"description": "The target HTML node for traversing."
}
],
"return": {
"type": "void"
}
}
],
"staticMethods": [],
"demos": [],
"metadata": {},
"sourceRange": {
"start": {
"line": 227,
"column": 8
},
"end": {
"line": 514,
"column": 1
}
},
"privacy": "public",
"superclass": "HTMLElement",
"attributes": [],
"events": [],
"styling": {
"cssVariables": [],
"selectors": []
},
"slots": [],
"tagname": "i18n-attr-repo"
},
{
"description": "",
"summary": "",
"path": "demo/preprocess/i18n-behavior-demo.js",
"properties": [
{
"name": "recipientsLength",
"type": "number | null | undefined",
"description": "",
"privacy": "public",
"sourceRange": {
"start": {
"line": 161,
"column": 4
},
"end": {
"line": 164,
"column": 5
}
},
"metadata": {
"polymer": {
"attributeType": "Number"
}
},
"defaultValue": "2"
},
{
"name": "recipientsIndex",
"type": "number | null | undefined",
"description": "",
"privacy": "public",
"sourceRange": {
"start": {
"line": 165,
"column": 4
},
"end": {
"line": 168,
"column": 5
}
},
"metadata": {
"polymer": {
"attributeType": "Number"
}
},
"defaultValue": "0"
},
{
"name": "langIndex",
"type": "number | null | undefined",
"description": "",
"privacy": "public",
"sourceRange": {
"start": {
"line": 169,
"column": 4
},
"end": {
"line": 172,
"column": 5
}
},
"metadata": {
"polymer": {
"attributeType": "Number"
}
},
"defaultValue": "0"
},
{
"name": "langList",
"type": "Array | null | undefined",
"description": "",
"privacy": "public",
"sourceRange": {
"start": {
"line": 173,
"column": 4
},
"end": {
"line": 178,
"column": 5
}
},
"metadata": {
"polymer": {
"attributeType": "Array"
}
},
"defaultValue": "[\"en\",\"fr\",\"ja\"]"
},
{
"name": "recipients",
"type": "Array | null | undefined",
"description": "",
"privacy": "public",
"sourceRange": {
"start": {
"line": 179,
"column": 4
},
"end": {
"line": 181,
"column": 5
}
},
"metadata": {
"polymer": {
"attributeType": "Array"
}
}
},
{
"name": "markdown",
"type": "string | null | undefined",
"description": "",
"privacy": "public",
"sourceRange": {
"start": {
"line": 182,
"column": 4
},
"end": {
"line": 187,
"column": 5
}
},
"metadata": {
"polymer": {
"notify": true,
"observer": "\"_markdownChanged\"",
"attributeType": "String"
}
},
"defaultValue": "\"\""
},
{
"name": "importMeta",
"type": "?",
"description": "",
"privacy": "public",
"sourceRange": {
"start": {
"line": 24,
"column": 2
},
"end": {
"line": 24,
"column": 25
}
},
"metadata": {
"polymer": {
"readOnly": false
}
}
}
],
"methods": [
{
"name": "attached",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 198,
"column": 2
},
"end": {
"line": 201,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
},
{
"name": "_langUpdated",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 203,
"column": 2
},
"end": {
"line": 205,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
},
{
"name": "_update",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 207,
"column": 2
},
"end": {
"line": 210,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "lang"
},
{
"name": "recipientsLength"
},
{
"name": "recipientsIndex"
},
{
"name": "rawRecipients"
}
],
"return": {
"type": "void"
}
},
{
"name": "_markdownChanged",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 212,
"column": 2
},
"end": {
"line": 214,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "markdown"
}
],
"return": {
"type": "void"
}
},
{
"name": "_getStringifiedRecipients",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 216,
"column": 2
},
"end": {
"line": 229,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "recipients"
}
]
},
{
"name": "_getStringifiedUser",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 231,
"column": 2
},
"end": {
"line": 233,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "user"
}
]
},
{
"name": "_getMarkDown",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 235,
"column": 2
},
"end": {
"line": 318,
"column": 3
}
},
"metadata": {},
"params": []
},
{
"name": "_getRecipients",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 320,
"column": 2
},
"end": {
"line": 331,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "rawRecipients"
},
{
"name": "recipientsLength"
},
{
"name": "recipientsIndex"
}
]
},
{
"name": "_jsonStringify",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 333,
"column": 2
},
"end": {
"line": 335,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "obj"
}
]
},
{
"name": "_getLangName",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 337,
"column": 2
},
"end": {
"line": 339,
"column": 3
}
},
"metadata": {},
"params": [
{
"name": "lang"
},
{
"name": "langNames"
}
]
},
{
"name": "_updateParameters",
"description": "",
"privacy": "protected",
"sourceRange": {
"start": {
"line": 341,
"column": 2
},
"end": {
"line": 355,
"column": 3
}
},
"metadata": {},
"params": [],
"return": {
"type": "void"
}
}
],
"staticMethods": [],
"demos": [],
"metadata": {},
"sourceRange": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 356,
"column": 1
}
},
"privacy": "public",
"superclass": "HTMLElement",
"attributes": [
{
"name": "recipients-length",
"description": "",
"sourceRange": {
"start": {
"line": 161,
"column": 4
},
"end": {
"line": 164,
"column": 5
}
},
"metadata": {},
"type": "number | null | undefined"
},
{
"name": "recipients-index",
"description": "",
"sourceRange": {
"start": {
"line": 165,
"column": 4
},
"end": {
"line": 168,
"column": 5
}
},
"metadata": {},
"type": "number | null | undefined"
},
{
"name": "lang-index",
"description": "",
"sourceRange": {
"start": {
"line": 169,
"column": 4
},
"end": {
"line": 172,
"column": 5
}
},
"metadata": {},
"type": "number | null | undefined"
},
{
"name": "lang-list",
"description": "",
"sourceRange": {
"start": {
"line": 173,
"column": 4
},
"end": {
"line": 178,
"column": 5
}
},
"metadata": {},
"type": "Array | null | undefined"
},
{
"name": "recipients",
"description": "",
"sourceRange": {
"start": {
"line": 179,
"column": 4
},
"end": {
"line": 181,
"column": 5
}
},
"metadata": {},
"type": "Array | null | undefined"
},
{
"name": "markdown",
"description": "",
"sourceRange": {
"start": {
"line": 182,
"column": 4
},
"end": {
"line": 187,
"column": 5
}
},
"metadata": {},
"type": "string | null | undefined"
}
],
"events": [
{
"type": "CustomEvent",
"name": "markdown-changed",
"description": "Fired when the `markdown` property changes.",
"metadata": {}
}
],
"styling": {
"cssVariables": [],
"selectors": []
},
"slots": [],
"tagname": "i18n-behavior-demo"
}
],
"metadata": {
"polymer": {
"behaviors": [
{
"description": "Apply `BehaviorsStore.I18nControllerBehavior` to manipulate internal variables for I18N\n\nNote: This behavior is not for normal custom elements to apply I18N. UI is not expected.",
"summary": "",
"path": "i18n-behavior.js",
"properties": [
{
"name": "isI18nController",
"type": "boolean | null | undefined",
"description": "Flag for detection of `I18nControllerBehavior`\n\n`true` if I18nControllerBehavior is applied\n\nNote: Module-specific JSON resources are NOT fetched for `I18nControllerBehavior`",
"privacy": "public",
"sourceRange": {
"start": {
"line": 93,
"column": 4
},
"end": {
"line": 97,
"column": 5
}
},
"metadata": {
"polymer": {
"readOnly": true,
"attributeType": "Boolean"
}
},
"defaultValue": "true"
},
{
"name": "html",
"type": "Object | null | undefined",
"description": "HTML element object for the current document",
"privacy": "public",
"sourceRange": {
"start": {
"line": 102,
"column": 4
},
"end": {
"line": 105,
"column": 5
}
},
"metadata": {
"polymer": {
"attributeType": "Object"
}
}
},
{
"name": "masterBundles",
"type": "Object | null | undefined",
"description": "Master bundles object for storing all the localized and default resources",
"privacy": "public",
"sourceRange": {
"start": {
"line": 110,
"column": 4
},
"end": {
"line": 113,
"column": 5
}
},
"metadata": {
"polymer": {
"attributeType": "Object"
}
}
},
{
"name": "defaultLang",
"type": "string | null | undefined",
"description": "Default lang for the document, i.e., the initial value of `<html lang>` attribute",
"privacy": "public",
"sourceRange": {
"start": {
"line": 118,
"column": 4
},
"end": {
"line": 122,
"column": 5
}
},
"metadata": {
"polymer": {
"readOnly": true,
"attributeType": "String"
}
}
},
{
"name": "bundleFetchingInstances",
"type": "Object | null | undefined",
"description": "List of elements which are fetching bundles",
"privacy": "public",
"sourceRange": {
"start": {
"line": 127,
"column": 4
},
"end": {
"line": 130,
"column": 5
}
},
"metadata": {
"polymer": {
"attributeType": "Object"
}
}
},
{
"name": "startUrl",
"type": "string | null | undefined",
"description": "Root URL path of the application ends with '/' to fetch bundles",
"privacy": "public",
"sourceRange": {
"start": {
"line": 135,
"column": 4
},
"end": {
"line": 139,
"column": 5
}
},
"metadata": {
"polymer": {
"readOnly": true,
"attributeType": "String"
}
}
},
{
"name": "localesPath",
"type": "string | null | undefined",
"description": "Path for locales\n\nDefault value is `'locales'`",
"privacy": "public",
"sourceRange": {
"start": {
"line": 146,
"column": 4
},
"end": {
"line": 150,
"column": 5
}
},
"metadata": {
"polymer": {
"readOnly": true,
"attributeType": "String"
}
}
},
{
"name": "attributesRepository",
"type": "Object | null | undefined",
"description": "<i18n-attr-repo> element to store attributes repository",
"privacy": "public",
"sourceRange": {
"start": {
"line": 155,
"column": 4
},
"end": {
"line": 159,
"column": 5
}
},
"metadata": {
"polymer": {
"readOnly": true,
"attributeType": "Object"
}
}
},
{
"name": "userPreference",
"type": "Object | null | undefined",
"description": "<i18n-preference> element",
"privacy": "public",
"sourceRange": {
"start": {
"line": 164,
"column": 4
},
"end": {
"line": 168,
"column": 5
}
},
"metadata": {
"polymer": {
"readOnly": true,
"attributeType": "Object"
}
}
}
],
"methods": [],
"staticMethods": [],
"demos": [],
"metadata": {},
"sourceRange": {
"start": {
"line": 83,
"column": 13
},
"end": {
"line": 170,
"column": 1
}
},
"privacy": "public",
"name": "I18nControllerBehavior",
"attributes": [
{
"name": "is-i18n-controller",
"description": "Flag for detection of `I18nControllerBehavior`\n\n`true` if I18nControllerBehavior is applied\n\nNote: Module-specific JSON resources are NOT fetched for `I18nControllerBehavior`",
"sourceRange": {
"start": {
"line": 93,
"column": 4
},
"end": {
"line": 97,
"column": 5
}
},
"metadata": {},
"type": "boolean | null | undefined"
},
{
"name": "html",
"description": "HTML element object for the current document",
"sourceRange": {
"start": {
"line": 102,
"column": 4
},
"end": {
"line": 105,
"column": 5
}
},
"metadata": {},
"type": "Object | null | undefined"
},
{
"name": "master-bundles",
"description": "Master bundles object for storing all the localized and default resources",
"sourceRange": {
"start": {
"line": 110,
"column": 4
},
"end": {
"line": 113,
"column": 5
}
},
"metadata": {},
"type": "Object | null | undefined"
},
{
"name": "default-lang",
"description": "Default lang for the document, i.e., the initial value of `<html lang>` attribute",
"sourceRange": {
"start": {
"line": 118,
"column": 4
},
"end": {
"line": 122,
"column": 5
}
},
"metadata": {},
"type": "string | null | undefined"
},
{
"name": "bundle-fetching-instances",
"description": "List of elements which are fetching bundles",
"sourceRange": {
"start": {
"line": 127,
"column": 4
},
"end": {
"line": 130,
"column": 5
}
},
"metadata": {},
"type": "Object | null | undefined"
},
{
"name": "start-url",
"description": "Root URL path of the application ends with '/' to fetch bundles",
"sourceRange": {
"start": {
"line": 135,
"column": 4
},
"end": {
"line": 139,
"column": 5
}
},
"metadata": {},
"type": "string | null | undefined"
},
{
"name": "locales-path",
"description": "Path for locales\n\nDefault value is `'locales'`",
"sourceRange": {
"start": {
"line": 146,
"column": 4
},
"end": {
"line": 150,
"column": 5
}
},
"metadata": {},
"type": "string | null | undefined"
},
{
"name": "attributes-repository",
"description": "<i18n-attr-repo> element to store attributes repository",
"sourceRange": {
"start": {
"line": 155,
"column": 4
},
"end": {
"line": 159,
"column": 5
}
},
"metadata": {},
"type": "Object | null | undefined"
},
{
"name": "user-preference",
"description": "<i18n-preference> element",
"sourceRange": {
"start": {
"line": 164,
"column": 4
},
"end": {
"line": 168,
"column": 5
}
},
"metadata": {},
"type": "Object | null | undefined"
}
],
"events": [],
"styling": {
"cssVariables": [],
"selectors": []
},
"slots": []
},
{
"description": "Apply `BehaviorsStore.I18nBehavior` to implement localizable elements.\n\n <dom-module id=\"custom-element\">\n <template>\n <span>Hard-coded UI texts are automatically made localizable</span>\n </template>\n <script>\n Polymer({\n is: 'custom-element',\n behaviors: [\n BehaviorsStore.I18nBehavior // Add this behavior\n ]\n });\n </script>\n </dom-module>\n\n`I18nBehavior` automatically extracts UI texts from `template` and\nbinds them to localizable variables in `this.text` object.\n\nAccording to the `lang` attribute value, `this.text`, and thus the bound UI texts,\ndynamically mutates by loading localized values from a JSON file in the `locales` directory.\nBy default, `lang` attribute values of all the localizable elements with `I18nBehavior` are\nautomatically updated according to `<html lang>` attribute value.\n\nThe UI text externalization can be processed at build time as well by `gulp-*` task\nso that `I18nBehavior` can immediately recognize the extracted texts in JSON and\nskip run-time externalization.\n\nRun-time externalization is suitable for development and debugging\nsince the code changes are immediately reflected at reloading without build-time preprocesses.\nIn contrast, build-time externalization is suitable for production builds\nsince it eliminates run-time externalization overheads.\n\n### Steps to localize a custom element\n\n1. [JavaScript] Add `BehaviorsStore.I18nBehavior` to `behaviors`\n1. [gulp] Add `gulp-*` filter for `custom-element.html` and generate `custom-element.json`\n1. [locales] Put `custom-element.lang.json` in `locales` directory\n1. [translation] Translate `locales/custom-element.lang.json`\n\n- - -\n\n### Directory structure of bundle files\n\nNormal bundles (`/element-root/locales/element-name.*.json`) for elements\nare stored under their root directories.\n\nShared bundles (`/locales/bundle.*.json`) are generated at build time\nby merging all the targeted bundles of the localizable elements.\n\nOnce the shared bundles are loaded, there should be no need to search for\nnormal bundles per element unless the element is intentionally excluded\nfrom the shared bundles.\n\n```\n /bundle.json\n /locales/bundle.ja.json\n /bundle.fr.json\n /bundle.zh-Hans.json\n\n /elements/my-list/my-list.json\n /locales/my-list.ja.json\n /my-list.zh-Hans.json\n\n /google-chart-demo/google-chart-demo.json\n /locales/google-chart-demo.ja.json\n /google-chart-demo.fr.json\n```\n\n- - -\n\n### Localizable `<template is=\"i18n-dom-bind\" id=\"app\">` element\n\n`<template is=\"i18n-dom-bind\">` template element extends\n`<template is=\"dom-bind\">` template element with all the capabilities of\n`I18nBehavior`.\n\nThe `id` attribute value is used for naming bundle files in