How to use app-localize-behavior in LitElement?

499 views
Skip to first unread message

dokfile...@gmail.com

unread,
Jul 22, 2018, 10:58:42 AM7/22/18
to Polymer
Hi All, 

Have any way to attache a behaviour in (LitElement)
lit-element, I want use : app-localize-behavior

Any idea how to port it to use with  lit-element.? like in mixinBehaviors([AppLocalizeBehavior], PolymerElement) ?
Thanks


hivelo...@gmail.com

unread,
Aug 9, 2018, 4:02:48 PM8/9/18
to Polymer
I'm currently attempting to do the same. I get the following error message:

err.PNG

Juan Lorenzo Llanes

unread,
Jan 28, 2019, 2:02:20 PM1/28/19
to Polymer
could Anyone resolve this issue?

rtf...@gmail.com

unread,
Feb 7, 2019, 4:44:31 PM2/7/19
to Polymer
try this:


// Import AppLocalizeBehavior
import {AppLocalizeBehavior} from '@polymer/app-localize-behavior';

// Import a utility class to treat legacy behaviors as mixins
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class';

class Editor extends connect(store)(mixinBehaviors([AppLocalizeBehavior], LitElement)) {
constructor() {
super();

this.resources = {
'en': { 'cancel':'Cancel' },
'es': { 'cancel':'Cancelar'}
};

this.language = 'en';
}

protected render() {
return html`

${this.localize('close')}

`;
}

Justin Fagnani

unread,
Feb 7, 2019, 5:25:34 PM2/7/19
to rtf...@gmail.com, Polymer
app-localize just wraps format.js. You'd be bringing in a lot of Polymer weight just for that. I'd try to use format.js directly or something lit-html specific like https://www.npmjs.com/package/@appnest/lit-translate

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/abde19a1-9fce-4ac6-b24e-dcbc32f3a077%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Juan Lorenzo Llanes

unread,
Feb 7, 2019, 8:34:14 PM2/7/19
to Polymer
I tried 

But I have an error with the mixin beacuse is waiting a PolymerElement instead a Litelement  

updating-element.ts:500 Uncaught TypeError: Cannot read property 'forEach' of undefined
    at HTMLElement._saveInstanceProperties (updating-element.ts:500)
    at HTMLElement.initialize (updating-element.ts:481)
    at HTMLElement.initialize (lit-element.ts:146)
    at new UpdatingElement (updating-element.ts:240)
    at new LitElement (lit-element.ts:88)
    at new PropertiesChanged (properties-changed.js:170)
    at new PropertyAccessors (property-accessors.js:115)
    at new TemplateStamp (template-stamp.js:125)
    at new PropertyEffects (property-effects.js:1195)
    at new PropertiesMixin (properties-mixin.js:115)

Juan Lorenzo Llanes

unread,
Feb 7, 2019, 8:36:51 PM2/7/19
to Polymer
Hi

I tried use lit-translate but only works in typescript environment and all the application to translate is writed in javascript :( :( 
Reply all
Reply to author
Forward
0 new messages