Ember-intl: Call missingMessage when translation key is empty

Created on 16 Aug 2018  Â·  5Comments  Â·  Source: ember-intl/ember-intl

Please consider the scenario where we have 2 translation files:

# en-us.yml
sample_translation:
    translation_1: Lorem ipsum
    translation_2: dolor sit amet
# de-de.yml
sample_translation:
    translation_1: Lorem ipsum
    translation_2: 

In this case while using German translations within the application, when we encounter sample_translation.translation_2 an error ‚A message must be provided as a String or AST.’ will be thrown and app will break.

If we could run missingMessage not only when translation is undefined, but also when it is null (key exists but there is no translation text) the error from MessageFormat won’t be thrown.

What do you think? Does it make any sense?

If it does, I can try to prepare PR for this one :)

stale

Most helpful comment

Hm, I see. 🙂

Maybe it would make more sense to strip these null keys during build time, since they unnecessarily inflate the size of the translations bundle?

If your translations tool does not support that, I'm sure we can accommodate for that. We wanted to beef up our build pipeline anyway. 💪

Would this be an alright solution for you?

All 5 comments

Out of curiosity, why do you not just remove the empty translation_2 key?

Actually this is the way my translations parser works. It returns all the keys for all the languages.
I don't know if anyone except me has a similar problem, that is why I added „Does it make any sense" part ;)

Hm, I see. 🙂

Maybe it would make more sense to strip these null keys during build time, since they unnecessarily inflate the size of the translations bundle?

If your translations tool does not support that, I'm sure we can accommodate for that. We wanted to beef up our build pipeline anyway. 💪

Would this be an alright solution for you?

This would be awesome! Thank you! 😃

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kilowhisky picture Kilowhisky  Â·  4Comments

richard-viney picture richard-viney  Â·  5Comments

jacobq picture jacobq  Â·  6Comments

sly7-7 picture sly7-7  Â·  3Comments

buschtoens picture buschtoens  Â·  6Comments