This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Starting work on support for Ember 1.13. Glimmer breaks the old helper and adds a new `Ember.Helper` with more of the power we need. 2. v1.13 introduces a new `Ember.Service` that should be the parent of the `service:i18n`. 3. Ember 2.0 removes `Ember.EnumerableUtils`, instead assuming all supported browsers supply the ES5 enumerable methods.
- Loading branch information
1 parent
a42a845
commit 7bf2973
Showing
6 changed files
with
68 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,23 @@ | ||
import Ember from "ember"; | ||
import Stream from "./stream"; | ||
import { readHash } from "./stream"; | ||
|
||
// @public | ||
export default function t(params, hash, options, env) { | ||
const i18n = env.data.view.container.lookup('service:i18n'); | ||
const i18nKey = params[0]; | ||
var Helper = null; | ||
|
||
var out = new Stream(function() { | ||
const value = i18nKey.isStream ? i18nKey.value() : i18nKey; | ||
return value === undefined ? '' : i18n.t(value, readHash(hash)); | ||
}); | ||
|
||
// observe any hash arguments that are streams: | ||
Ember.keys(hash).forEach(function(key) { | ||
const value = hash[key]; | ||
|
||
if (value && value.isStream) { | ||
value.subscribe(out.notify, out); | ||
} | ||
}); | ||
if (Ember.Helper) { | ||
Helper = Ember.Helper.extend({ | ||
i18n: Ember.inject.service(), | ||
|
||
// observe the locale: | ||
i18n.localeStream.subscribe(out.notify, out); | ||
_locale: Ember.computed.readOnly('i18n.locale'), | ||
|
||
// if the i18n key itself is dynamic, observe it: | ||
if (i18nKey.isStream) { | ||
i18nKey.subscribe(out.notify, out); | ||
} | ||
compute: function(params, interpolations) { | ||
const key = params[0]; | ||
const i18n = this.get('i18n'); | ||
return i18n.t(key, interpolations); | ||
}, | ||
|
||
return out; | ||
_recomputeOnLocaleChange: Ember.observer('_locale', function() { | ||
this.recompute(); | ||
}) | ||
}); | ||
} | ||
|
||
export default Helper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Ember from "ember"; | ||
import Stream from "./stream"; | ||
import { readHash } from "./stream"; | ||
|
||
var helper = null; | ||
|
||
if (Ember.Helper == null) { | ||
// @public | ||
helper = function tHelper(params, hash, options, env) { | ||
const i18n = env.data.view.container.lookup('service:i18n'); | ||
const i18nKey = params[0]; | ||
|
||
var out = new Stream(function() { | ||
const value = i18nKey.isStream ? i18nKey.value() : i18nKey; | ||
return value === undefined ? '' : i18n.t(value, readHash(hash)); | ||
}); | ||
|
||
// observe any hash arguments that are streams: | ||
Ember.keys(hash).forEach(function(key) { | ||
const value = hash[key]; | ||
|
||
if (value && value.isStream) { | ||
value.subscribe(out.notify, out); | ||
} | ||
}); | ||
|
||
// observe the locale: | ||
i18n.localeStream.subscribe(out.notify, out); | ||
|
||
// if the i18n key itself is dynamic, observe it: | ||
if (i18nKey.isStream) { | ||
i18nKey.subscribe(out.notify, out); | ||
} | ||
|
||
return out; | ||
}; | ||
} | ||
|
||
export default helper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters