synacor / preact-i18n

Simple localization for Preact.
BSD 3-Clause "New" or "Revised" License
205 stars 18 forks source link

Text is not rendered out when used as a field for Text #29

Closed mogsdad closed 5 years ago

mogsdad commented 5 years ago

Given a dictionary containing:

    "error": {
        "any": "Error: {{e}}",
        "genericInvalidRequest": "An unknown error has occurred."
    }

Providing <Text> as a field, like this: <Text id="error.any" fields={{ e: <Text id="error.genericInvalidRequest" /> }} />

Does not render the field: Error: [object Object]

billneff79 commented 5 years ago

@mogsdad - until this is resolved, you can use the withText helper function to supply error.genericInvalidRequest's localized value to the component as an already resolved value. e.g.

withText('error.genericInvalidRequest')(({genericInvalidRequest}) => <Text id="error.any" fields={{e: genericInvalidRequest }} /> )
pl12133 commented 5 years ago

Fixed by https://github.com/synacor/preact-i18n/pull/30