globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

Accessing other dictionary entries from within the messageFormatter #782

Closed AndreR closed 7 years ago

AndreR commented 7 years ago

Is there a simple way to reuse other dictionary entries in a messageFormatter path. For example "Please click the {saveButtonText} button, to save your changes."

With this approach, Globalize will throw an error, as long as I don't pass the value of saveButtonText as a parameter:

Globalize.formatMessage('saveButtonDescription', {saveButtonText: Globalize.formatMessage('saveButtonText'});

Is there a way to simplify this call, so that the developer doesn't have to monitor which other pre-defined strings are used?

rxaviers commented 7 years ago

On a message, there's no way to reference another message. It's also not a common practice to concat messages inside another messages. Usually, you have complete messages. Note positioning, gender inflection, pluralization, and other stuff might change from languages to languages and the concat approach is error prone.

AndreR commented 7 years ago

Thank you very much for the clarification!