Comments (5)
@al3x-edge in the example, boundProperty
should have the value of the message, which is:
boundProperty === `You have {numPhotos, plural,
=0 {no photos.}
=1 {one photo.}
other {# photos.}}`
The other option is to use the lookup helper intl-get
, which will simply try to find the message value by key, which is the recommended way.
from ember-intl.
@caridy Thanks for the answer -- Just as a follow up -- Is there a way to get the value of the message in a controller assuming it's injected?
from ember-intl.
Is there a way to get the value of the message in a controller assuming it's injected?
You want to resolve a translation key to a message from a computed property on your controller?
Based on your initial question, I'm unsure if you're dealing with a string literal or a translation key from your computed property, so I've included examples for both:
// index fontroller
export default Ember.Controller.extend({
dependentKey: false,
actions: {
toggle: function () {
this.toggleProperty('dependentKey');
}
},
literalString: Ember.computed('dependentKey', function () {
var dep = this.get('dependentKey');
return dep ? 'yes' : 'no';
}),
lookupString: Ember.computed('dependentKey', function () {
var dep = this.get('dependentKey');
return dep ? 'messages.foo' : 'messages.bar';
})
});
from ember-intl.
@al3x-edge your last question might also be related to #89
Let me know
from ember-intl.
Thanks for the reference to #89 -- When asking the question, that is what I was looking for once the boundProperty didn't work. I'll keep this as reference.
Originally tried the second approach with setting a lookupString but was getting errors for some reason. Recently updated all dependencies though -- not sure if something took or I just did it right the second time around -- and everything is fine.
Thanks for the help (@jasonmit / @caridy ). Greatly appreciated.
from ember-intl.
Related Issues (20)
- Missing fast-memoize module when updating ember-auto-import HOT 1
- Problems with adding Somali language - intl-numberformat error HOT 7
- When will there be another release? HOT 1
- Type issues from Registry HOT 6
- Type issues from -format-base.d.ts HOT 1
- bump typescript peer dependency to 5 HOT 3
- trailingZeroDisplay not working HOT 2
- FORMAT_ERROR when using the `Intl.RelativeTimeFormat` polyfill with `v6.0.0` of ember-intl HOT 3
- Double `intl.d.ts` cause type errors HOT 8
- Unexpected locale `en-us` after upgrade to ember-intl v6 HOT 6
- A simple, autogenerated integration test fails for a component using a translation in ember-intl 6.1.2 HOT 6
- Bundle size regression in v6.2.0 HOT 3
- Merge this into formatjs HOT 3
- Incompatible with native `ember-source` types HOT 5
- `allowEmpty` class property not respected in v6.3.1 HOT 1
- Extending helpers like FormatDate has braking changes between v6.2.2 and v6.3.0+ HOT 5
- Basic usage results in: You attempted to update `_locale` [...] infinite revalidation bugs, and performance issues, and is not supported. HOT 4
- How to use `publicOnly: true` in Embroider apps HOT 10
- v6 - Error on valid use of `many`: message cannot be parsed: Unknown plural category: many HOT 1
- Deleted
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-intl.