Giter Club home page Giter Club logo

i18n-behavior's Introduction

i18n-behavior's People

Contributors

t2ym avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

i18n-behavior's Issues

Incompatible with Polymer 1.2.4

Not working with Polymer 1.2.4 while working well with Polymer 1.2.3

Workaround: Rollback to Polymer 1.2.3 until an appropriate fix is created.

[Polymer 1.3.0] observeHtmlLang is undefined in i18n-dom-bind

With Polymer 1.3.0, i18n-dom-bind.observeHtmlLang property is not initialized and its value is undefined at dom-change event.

If the value is manually set as true, the property works well.

If the template is="i18n-dom-bind" element has the corresponding attribute observe-html-lang, the issue is not reproducible.

Hyphens are not allowed in bound variable names since Polymer 1.2.4

If id or text-id attribute is missing and the target element name contains hyphens, bindings of preprocessed annotations fail for the element.

For example, this paper-button element lacks explicit id and thus its string id is generated with paper-button with a hyphen. So the binding with {{text.paper-button}} fails with Polymer 1.2.4, while it succeeds with Polymer 1.2.3.

   <paper-button>label</paper-button>

locale names are case-sensitive

Locale names are case-sensitive and thus cannot match with the target locales.

If lang is FR-ca, it must match with fr-CA language if exists.

[IE11] textContent is not properly parsed for i18n-format parameters

In InternetExplorer 11, textContent is not properly parsed for i18n-format parameters and only the first text node child is extracted.

The root cause is the strange parser in IE11 which divides hyphenated textContent to multiple text nodes like this:

HTML:
<span>A-B-C</span>

DOM:

<span>
  A
  -
  B
  -
  C
</span>

Only A is extracted in this case.

[ShadowDOMPolyfill] MutationObserver cannot catch property changes

Even in Shady DOM mode, MutationObserver cannot catch property value mutations, while mutation of html.lang property has to be watched.

The root cause is ShadowDOM's polyfilled MutationObserver, which cannot catch property changes but attribute changes.

The issue is reproducible when webcomponents[.min].js polyfills Shadow DOM. Chrome with native Shadow DOM is not affected.

[Polymer CLI] Handle polymer serve response falling back to the entrypoint html

With Polymer CLI, polymer serve response falls back to the entrypoint html for any inexistent paths instead of 404 Not Found. So the client can misjudge the real entrypoint url.

Should this non-standard response be handled? It may be a practical case that the HTTP server is configured to provide the entry point contents for the URL path generated by the client-side router so that the browser can bookmark the virtual path of the SPA or reload the contents from the path.

Since 404 Not Found should be responded properly, it may be better to configure the HTTP server to redirect requests for valid virtual paths to valid real paths like /?virtualPath=/original/valid/virtual/path, which can be interpreted by the entrypoint as the virtual paths for the client-side router.

Original Issue:
#50

[Enhancement] Selective I18N-target attributes

Support selective I18N-target attributes.

For example, pick up value="Button Label" attribute of <input> tag if type="button"

Example selective attribute:

<input type="button" value="Button Label">

Expected Definition:

<i18n-attr-repo>
  <template id="custom">
    <input value="type=button|submit">
  </template>
</i18n-attr-repo>

Workaround as of version 1.0.1:

<i18n-attr-repo>
  <template id="custom">
    <input label="$"><!-- define label as I18n-target attribute -->
  </template>
</i18n-attr-repo>

<dom-module id="my-element">
  <template>
    <!-- forward to the 'value' attribute -->
    <input id="ok-button"
      value="{{text.model.ok-button.label}}"
      on-click="_ok"
      label="OK">
  </template>
</dom-module>

[test][SauceConnect] socket.io request from Edge browser is responded with "400 Bad Request"

[SauceConnect] socket.io request from Edge browser is responded with "400 Bad Request"

This may be the root cause of the dropped SauceConnect test results from Edge, Safari 8/9 browsers.

It seems that sec-websocket-key header exists in bad cases (e.g. Edge) while no such headers in good cases (e.g. IE11).

Microsoft Edge: Bad Request

GET /socket.io/?EIO=3&transport=websocket&sid=Ua5gvtWS7ZSY-b5_AAAA HTTP/1.1
Origin: http://localhost:2000
sec-websocket-version: 13
Host: localhost:2000
sec-websocket-key: MVDjG3DPMODvSFiagBDskg==
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586
Cookie: io=Ua5gvtWS7ZSY-b5_AAAA
Content-Length: 0
Via: 1.1 maki79134 (squid/3.4.6)
Cache-Control: no-cache
Connection: keep-alive

HTTP/1.1 400 Bad Request
Content-Type: application/json
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:2000
Date: Thu, 02 Jun 2016 00:11:28 GMT
Connection: keep-alive
Transfer-Encoding: chunked

22
{"code":3,"message":"Bad request"}
0

IE11: Good Response

GET /socket.io/?EIO=3&transport=polling&t=LKEWVgk&sid=yw7eY_MbCTCzbjS5AAAA HTTP/1.1
Accept: */*
Referer: http://localhost:2000/components/i18n-behavior/generated-index.html?cli_browser_id=0
Accept-Language: en-US
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost:2000
Cookie: io=yw7eY_MbCTCzbjS5AAAA
Via: 1.1 maki78064 (squid/3.4.6)
Cache-Control: max-age=0
Connection: keep-alive

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 5
Access-Control-Allow-Origin: *
X-XSS-Protection: 0
Set-Cookie: io=yw7eY_MbCTCzbjS5AAAA
Date: Thu, 02 Jun 2016 00:27:27 GMT
Connection: keep-alive

^@^B<FF>40

Child templates (dom-repeat, dom-if) are not properly rendered when i18n-format is applied

When i18n-format is automatically applied, child templates such as dom-repeat, dom-if are not properly rendered.

Paragraph with a child template:

  <p id="paragraph">
    A paragraph with 
    <template is="dom-repeat" items="{{text.parameters}}">
      <i>{{item}} </i>
    </template>
    is converted to 
    <code>&lt;i18n-format&gt;</code>.
  </p>

Expected preprocess:

  <p id="paragraph">
    <i18n-format lang="{{effectiveLang}}">
      <span>{{text.paragraph.0}}</span>
      <template is="dom-repeat" items="{{text.parameters}}">
        <i param="1">{{item}} </i>
      </template>
      <code param="2">{{text.paragraph.2}}</code>
    </i18n-format>
  </p>

Actual preprocess: The rendered <i> is not selected for <content select='[param="1"]'></content>.

  <p id="paragraph">
    <i18n-format lang="{{effectiveLang}}">
      <span>{{text.paragraph.0}}</span>
      <template param="1" is="dom-repeat" items="{{text.parameters}}">
        <i>{{item}} </i>
      </template>
      <code param="2">{{text.paragraph.2}}</code>
    </i18n-format>
  </p>

If contents of the child template have more than 1 elements or have compound bindings, i18n-format must not be applied.

Slightly Incompatible with Polymer 1.3.0

templateDefaultLang property value becomes undefined due to the breaking change for the String and Function type property with a function value in Polymer 1.3.0

It works well with Polymer 1.2.4 but does not work with Polymer 1.3.0.

    properties: {
      templateDefaultLang: {
        type: String,
        value: function () { ... return value; }
      }
    }

Since Polymer 1.3.0, type must be Function if the value is a function.

    properties: {
      templateDefaultLang: {
        type: Function,
        value: function () { ... return value; }
      }
    }

[IE 10] i18n-dom-bind does not work on IE 10

On Internet Explorer 10, i18n-dom-bind does not work.

Root cause: Incomplete prototype is specified at the element registration due to incompatible Object.getPrototypeOf() on IE 10.

Possible fix is to use the deprecating .__proto__ as fallback.

[TODO] Empty cases have to be handled properly

If no strings are defined or no template is available, an empty bundle have to be used as a fallback.

Currently, _constructDefaultBundle() just returns false and gave up in such cases.

[IE11][Polymer 1.3.0] On IE11, i18n-dom-bind does not work with Polymer 1.3.0

On Internet Explorer 11, i18n-dom-bind does not work with Polymer 1.3.0.

The computed: '_getBundle(lang)' does not function for 'this.text' dynamic object property.
this._getBundle(this.lang) itself works well but this.text is undefined.

The root cause seems to be another side effect of the breaking changes in Function properties in Polymer 1.3.0.

Shared bundle.{lang}.json does not fall back to its element-specific el.{lang}.json

If the shared bundle for {lang} (locales/bundle.{lang}.json) is missing,
its element-specific bundle my-element.{lang}.json is not fetched and the language unexpectedly falls back.

The root cause is the missing logic for a missing shared bundle.

When multiple elements are trying to fetch their bundles in parallel, the issue does not reproduce.

[enhancement] Add tr(key,table) method to translate a string

A new method tr(key,table) which returns table[key].

Example Usage:

   <span>{{tr(status,text.statusMsgs)}}</span>
   <span>{{tr(errorId,text)}}</span>
   <template>
    <json-data text-id="statusMsgs">{
       "signed-in": "Authenticated",
       "signed-out": "Not Authenticated",
       "error": "Error in Authentication"
     }</json-data>
     <span text-id="http-404">File Not Found</span>
     <span text-id="http-301">Moved Permanently</span>
   </template>

Test suite inheritance does not work for zh-Hans-CN fallback to default test

Test suite inheritance by Object.setPrototypeOf is polyfilled by a function with Object.create but still 1 suite cannot be inherited, which is patched as follows:

    s(lang5 + ' simple text with fallback to default', 'simple text', {
      fixture: 'simple-text-element', // redundant
      fixtureModel: { observeHtmlLang: false, lang: lang0 },  // redundant
      assign: { lang: lang5 },
      lang: lang0, // redundant
      effectiveLang: lang0, // redundant
      templateDefaultLang: lang1, // redundant
      observeHtmlLang: false, // redundant
      text: text_simple, // redundant
      model: {}, // redundant
      localDOM: localDOM_simple, // redundant
      lightDOM: undefined // redundant
    }),

[Enhancement] Compound binding support for I18N-target attributes

Compound binding support for I18N-target attributes.

Parameterized:

  attr="Compound binding attribute has [[bound.value]] {{parameters}} in the value string"
  "{{i18nFormat(attrId.0,bound.value,parameters)}}"
  [ "Compound binding attribute has {1} {2} in the value string", "[[bound.value]]", "{{parameters}}" ]

Concatenated: (Parameters with functions cannot be reordered in translation)

  attr2="Compound binding attribute has [[f1(bound.value)]] {{f2(parameters)}} in the value string"
  "{{attrId.0}}[[f1(bound.value)]]{{attrId.2}}{{f2(parameters)}}{{attrId.4}}"
  [ "Compound binding attribute has ", "[[f1(bound.value)]]", " ", "{{f2(parameters)}}", " in the value string" ]

Bundle JSON files are fetched from a wrong path when window.location is altered

Bundle JSON files (locales/bundle.*.json) are fetched from a wrong path when window.location is altered from the start url.

The initial value for window.location at the main page loading has to be stored as the start URL for the SPA app instead of using the current window.location value.

Note: Since Polymer CLI 0.12.0's polymer serve serves the entrypoint content (index.html) for all the inexistent URLs instead of 404 Not Found, window.location value is wrong at the initial loading and thus cannot be handled properly. Just reload from the start URL.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.