intl.lookup() no longer using missingMessage()?
See original GitHub issueHi,
I’m working on migrating a project from ember-intl 4 to 5 and there’s a reliance on intl.lookup()
calling the missingMessage()
function when a key is passed in with no corresponding message.
It looks like this no longer happens in v5? It seems like lookupAST()
does call missingMessage()
but that’s not part of the public API.
I can probably work around this by manually calling missingMessage()
if intl.lookup()
returns an undefined
or possibly just using lookupAST()
instead. I’m just raising this here in case it’s determined this was a breaking change and there’s a reasonable way to reintroduce the old behavior.
Apologies if I missed anything obvious and please let me know if there’s anything else I can do to help.
- I am on the latest ember-intl version
- I have searched the issues of this repo and believe that this is not a duplicate
Environment
- Ember Version: 3.13 (production) 3.20 (test)
- Ember CLI Version: 3.13 (production) 3.20 (test)
- Ember Intl Version: 5.4.2
- Browser(s): firefox 79, chrome 84
- Node Version: 14.7.0
Steps to Reproduce
- Call
intl.lookup('a key that does not have a message')
- See that the no warning is generated for the missing key.
- Optionally create
app/utils/intl/missing-message.js
with custom behavior and see that the overriden function is not called.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How handle "missing message" error in react-intl?
Provide your own error handler (without a console.error ) and the console error should go away. Share.
Read more >Empty string treated as missing message · Issue #607 - GitHub
formatMessage treats a message of "" (empty) string (and 0, and any other "falsy" value) the same as a missing message, resulting in:...
Read more >Translate Create-React-App with React-Intl - Frontend Digest
How to set up react-intl with CRA without ejecting ... App.css";function App() { return ( <IntlProvider ... [React Intl] Missing message: “Header.
Read more >Imperative API | Format.JS
When using React Intl you'll be interacting with its API (documented ... This useIntl hook does not expect any option as its argument...
Read more >Extending react-intl with your own markup - Keypup
Creating your own wrapper will simplify your code and give more power to your translation keys. When it comes to internationalization in React ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Perfect, since the API was broken from the beginning I’ll treat this as a breaking change and will update the 4 to 5 migration docs to call it out. You can safely assume missing messages won’t return and break your app again 😃
I’ll write a test for asserting
undefined
is returned on missing translations vialookup()
, update the docs, and close the issue tonight. Thanks!Yeah, exactly. Doing the string inspection is definitely not needed at all. Like I said above, I’m not desperate for the old behavior to come back, once I get things cleaned up I personally won’t need it anymore. I just decided to write it up as an issue in case there was consensus that it needed to come back.
I’m totally fine with just documenting the change in behavior and moving on. I appreciate the quick response and the work you put in maintaining this library!