Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-i18n

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-i18n - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0

26

addon/helper.js
import Ember from "ember";
export default Ember.Helper.extend({
i18n: Ember.inject.service(),
const { get, inject, Helper, Object: EmberObject, observer } = Ember;
compute: function(params, interpolations) {
const key = params[0];
const i18n = this.get('i18n');
return i18n.t(key, interpolations);
function mergedContext(objectContext, hashContext) {
return EmberObject.extend({
unknownProperty(key) {
const fromHash = get(hashContext, key);
return fromHash === undefined ? get(objectContext, key) : fromHash;
}
}).create();
}
export default Helper.extend({
i18n: inject.service(),
compute([key, contextObject = {}, ...rest], interpolations) {
const mergedInterpolations = mergedContext(contextObject, interpolations);
const i18n = get(this, 'i18n');
return i18n.t(key, mergedInterpolations);
},
_recomputeOnLocaleChange: Ember.observer('i18n.locale', function() {
_recomputeOnLocaleChange: observer('i18n.locale', function() {
this.recompute();
})
});
import Stream from "./stream";
import { readHash } from "./stream";
import Ember from 'ember';
export default function tHelper(params, hash, options, env) {
const assign = Ember.assign || Ember.merge;
export default function tHelper([i18nKey, contextObject = { value: () => {} }], 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));
const contextObjectValue = contextObject.value();
const mergedHash = {};
assign(mergedHash, contextObjectValue);
assign(mergedHash, hash);
return value === undefined ? '' : i18n.t(value, readHash(mergedHash));
});

@@ -18,2 +28,6 @@

if (contextObject && contextObject.isStream) {
contextObject.subscribe(out.notify, out);
}
// observe any hash arguments that are streams:

@@ -20,0 +34,0 @@ Object.keys(hash).forEach(function(key) {

@@ -0,1 +1,6 @@

## 4.5.0
* `{{t}}` helper supports a context object as a second ordered argument;
named (hash) arguments override context object ones when interpolating
## 4.4.0

@@ -2,0 +7,0 @@

{
"name": "ember-i18n",
"version": "4.4.0",
"version": "4.5.0",
"description": "Internationalization for Ember",

@@ -5,0 +5,0 @@ "directories": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc