Comparing version 0.2.3 to 0.2.5
import Ember from 'ember'; | ||
const SafeString = Ember.String.htmlSafe || Ember.Handlebars.SafeString; | ||
export function tr(params, hash) { | ||
@@ -15,3 +17,3 @@ var label = params[0]; | ||
) { | ||
return new Ember.Handlebars.SafeString(window.tr(label, description, hash)); | ||
return new SafeString(window.tr(label, description, hash)); | ||
} else { | ||
@@ -18,0 +20,0 @@ return label; |
import Ember from 'ember'; | ||
const SafeString = Ember.String.htmlSafe || Ember.Handlebars.SafeString; | ||
export function trl(params, hash) { | ||
@@ -15,3 +17,3 @@ var label = params[0]; | ||
) { | ||
return new Ember.Handlebars.SafeString(window.trl(label, description, hash)); | ||
return new SafeString(window.trl(label, description, hash)); | ||
} else { | ||
@@ -18,0 +20,0 @@ return label; |
import config from '../config/environment'; | ||
const {merge} = Ember; | ||
export function initialize() { | ||
@@ -13,7 +15,9 @@ let application = arguments[1] || arguments[0]; | ||
try { | ||
window.tml.init(config.tml, function(){ | ||
let opts = merge({source: (config.modulePrefix || 'Ember Application')}, config.tml); | ||
window.tml.init(opts, function(){ | ||
application.advanceReadiness(); | ||
}); | ||
} catch(e) { | ||
console.log(e); | ||
application.advanceReadiness(); | ||
@@ -20,0 +24,0 @@ } |
{ | ||
"name": "ember-tml", | ||
"version": "0.2.3", | ||
"version": "0.2.5", | ||
"description": "Ember addon for advanvced localization using TML(Translation Markup Language) from Translation Exchange.", | ||
@@ -5,0 +5,0 @@ "directories": { |
#Ember TML | ||
# Ember TML | ||
@@ -9,3 +9,3 @@ This addon adds helpers for doing advanced localization of your ember apps with Translation Markup Language (TML) by Translation Exchange. | ||
##Installation | ||
## Installation | ||
@@ -17,3 +17,3 @@ ````javascript | ||
##Configuration | ||
## Configuration | ||
@@ -36,3 +36,3 @@ The first thing you need to do to get started with Ember TML is sign up for a free [Translation Exchange](https://translationexchange.com/) account and create your first project. | ||
##Content Security Policy | ||
## Content Security Policy | ||
@@ -58,3 +58,3 @@ If you're using the content security policy, you'll need to add the translationexchange domain to allow loading of remote scripts. | ||
##Usage | ||
## Usage | ||
@@ -109,6 +109,7 @@ The Ember TML Addon provides a few helpers and a service: | ||
###API | ||
####TML Service Api | ||
### API | ||
#### TML Service Api | ||
The TML service will be injected into `Controllers`, `Routes`, `Views` and `Components`. | ||
@@ -121,5 +122,5 @@ | ||
- **`currentTranslator`** | ||
an object representing the current logged in translator | ||
````javascript | ||
**`currentTranslator`** | ||
an object representing the current logged in translator | ||
````javascript | ||
Ember.get(this, 'tml.currentTranslator'); | ||
@@ -132,5 +133,5 @@ // { | ||
- **`currentSource`** | ||
a string of the current source | ||
````javascript | ||
**`currentSource`** | ||
a string of the current source | ||
````javascript | ||
Ember.get(this, 'tml.currentSource'); | ||
@@ -140,5 +141,5 @@ // "index" | ||
- **`currentApplication`** | ||
return an object representing your Translation Exchange application | ||
````javascript | ||
**`currentApplication`** | ||
return an object representing your Translation Exchange application | ||
````javascript | ||
Ember.get(this, 'tml.currentApplication'); | ||
@@ -156,22 +157,46 @@ // { | ||
- **`currentLanguage`** | ||
returns the currently selected language | ||
**`currentLanguage`** | ||
returns the currently selected language | ||
````javascript | ||
Ember.get(this, 'tml.currentLanguage'); | ||
// { | ||
// id: 233, | ||
// english_name: "Russian", | ||
// native_name: "Русский", | ||
// locale: "ru", | ||
// right_to_left: false, | ||
// flag_url: "https://s3-us-west-1.amazonaws.com/trex-snapshots/flags/default/languages/16/ru.png" | ||
// } | ||
```` | ||
**`availableLanguages`** | ||
returns a list of all available languages for your project | ||
- **`availableLanguages`** | ||
returns a list of all available languages for your project | ||
**`translationModeEnabled`** | ||
returns whether or not the application is currently in translation mode | ||
- **`translationModeEnabled`** | ||
returns whether or not the application is currently in translation mode | ||
**`translate(label [,description, tokens])`** | ||
**`tr(label [,description, tokens])`** | ||
works the same as the `tr` helper | ||
- **`translate(label [,description, tokens])`** | ||
**`tr(label [,description, tokens])`** | ||
works the same as the `tr` helper | ||
**`translateLabel(label [,description, tokens])`** | ||
**`trl(label [,description, tokens])`** | ||
works the same as the `trl` helper | ||
- **`translateLabel(label [,description, tokens])`** | ||
**`trl(label [,description, tokens])`** | ||
works the same as the `trl` helper | ||
**`changeLanguage(locale)`** | ||
sets the current language | ||
- **`changeLanguage(locale)`** | ||
sets the current language | ||
### Building a Language Selector | ||
````handlebars | ||
<ul> | ||
{{#each tml.availableLanguages as |language|}} | ||
<li> | ||
<a {{action (action tml.changeLanguage) language.locale}}> | ||
<img src={{language.flag_url}} /> | ||
{{tr language.english_name}} | ||
</a> | ||
</li> | ||
{{/each}} | ||
</ul> | ||
```` | ||
@@ -181,1 +206,3 @@ | ||
13101
199
19
176