All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.polymer.app.AppLocalizeBehavior Maven / Gradle / Ivy

The newest version!
/*
 * This code was generated with Vaadin Web Component GWT API Generator, 
 * from app-localize-behavior project by The Polymer Authors
 * that is licensed with http://polymer.github.io/LICENSE.txt license.
 */
package com.vaadin.polymer.app;

import com.vaadin.polymer.elemental.*;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;


/**
 * 

Polymer.AppLocalizeBehavior wraps the format.js library to
help you internationalize your application. Note that if you’re on a browser that
does not natively support the Intl
object, you must load the polyfill yourself. An example polyfill can
be found here.

*

Polymer.AppLocalizeBehavior supports the same 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:

*
<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:

*
<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>
 * 
 * 
 * 
*/ @JsType(isNative=true) public interface AppLocalizeBehavior { @JsOverlay public static final String NAME = "Polymer.AppLocalizeBehavior"; @JsOverlay public static final String SRC = "app-localize-behavior/app-localize-behavior.html"; /** *

If true, will bubble up the event to the parents

* * JavaScript Info: * @property bubbleEvent * @type Boolean * */ @JsProperty boolean getBubbleEvent(); /** *

If true, will bubble up the event to the parents

* * JavaScript Info: * @property bubbleEvent * @type Boolean * */ @JsProperty void setBubbleEvent(boolean value); /** *

Optional dictionary of user defined formats, as explained here:
http://formatjs.io/guides/message-syntax/#custom-formats

*

For example, a valid dictionary of formats would be:
this.formats = {
number: { USD: { style: ‘currency’, currency: ‘USD’ } }
}

* * JavaScript Info: * @property formats * @type Object * */ @JsProperty JavaScriptObject getFormats(); /** *

Optional dictionary of user defined formats, as explained here:
http://formatjs.io/guides/message-syntax/#custom-formats

*

For example, a valid dictionary of formats would be:
this.formats = {
number: { USD: { style: ‘currency’, currency: ‘USD’ } }
}

* * JavaScript Info: * @property formats * @type Object * */ @JsProperty void setFormats(JavaScriptObject value); /** *

Translates a string to the current language. Any parameters to the
string should be passed in order, as follows:
localize(stringKey, param1Name, param1Value, param2Name, param2Value)

* * JavaScript Info: * @property localize * @type Function * */ @JsProperty Function getLocalize(); /** *

Translates a string to the current language. Any parameters to the
string should be passed in order, as follows:
localize(stringKey, param1Name, param1Value, param2Name, param2Value)

* * JavaScript Info: * @property localize * @type Function * */ @JsProperty void setLocalize(Function value); /** *

The dictionary of localized messages, for each of the languages that
are going to be used. See http://formatjs.io/guides/message-syntax/ for
more information on the message syntax.

*

For example, a valid dictionary would be:
this.resources = {
‘en’: { ‘greeting’: ‘Hello!’ }, ‘fr’ : { ‘greeting’: ‘Bonjour!’ }
}

* * JavaScript Info: * @property resources * @type Object * */ @JsProperty JavaScriptObject getResources(); /** *

The dictionary of localized messages, for each of the languages that
are going to be used. See http://formatjs.io/guides/message-syntax/ for
more information on the message syntax.

*

For example, a valid dictionary would be:
this.resources = {
‘en’: { ‘greeting’: ‘Hello!’ }, ‘fr’ : { ‘greeting’: ‘Bonjour!’ }
}

* * JavaScript Info: * @property resources * @type Object * */ @JsProperty void setResources(JavaScriptObject value); /** *

If true, will use the provided key when
the translation does not exist for that key.

* * JavaScript Info: * @property useKeyIfMissing * @type Boolean * */ @JsProperty boolean getUseKeyIfMissing(); /** *

If true, will use the provided key when
the translation does not exist for that key.

* * JavaScript Info: * @property useKeyIfMissing * @type Boolean * */ @JsProperty void setUseKeyIfMissing(boolean value); /** *

The language used for translation.

* * JavaScript Info: * @property language * @type String * */ @JsProperty String getLanguage(); /** *

The language used for translation.

* * JavaScript Info: * @property language * @type String * */ @JsProperty void setLanguage(String value); /** * * * JavaScript Info: * @method loadResources * @param {} path * * */ void loadResources(Object path); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy