Socket
Socket
Sign inDemoInstall

ember-intl-component

Package Overview
Dependencies
505
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ember-intl-component

The default blueprint for ember-cli addons.


Version published
Maintainers
1
Created

Readme

Source

ember-intl-component

Allows using component to render i18n strings and substitute attributes with components.

translation.key: '<p>Lets test {count, plural, =1 {# complex part} other {# complex parts}} with {type}. [[[link]]] to the outer world. Or [[[component]]].</p>',
<I18n @i18nid="translation.key" @type="XML" @count="2" as |MessageScope|>
  <MessageScope>
    <:link>
      <a href="https://ember-intl.github.io/ember-intl/">ember-intl</a>
    </:link>
    <:component>
      <TestComponent @text="Explore ember-intl"/>
    </:component>
  </MessageScope>
</I18n>

Compatibility

  • Ember.js v3.20 or above
  • Ember CLI v3.20 or above
  • Node.js v12 or above

Installation

ember install ember-intl-component

Usage

How does it work?

i18n component creates new components dynamically in runtime for each individual translation key. As a first step, translation will be passed through ember-intl t helper, then processed with withing i18n component.

Using

Simple case

welcome: 'Welcome, {name}!',
<I18n @i18nid="welcome" @name="Zoe" />

P.S in cases like that, it's better to use just {{t}} helper.

With component usage

translation.key: 'With component: [[[welcome]]]',
<I18n @i18nid="translation.key" as |MessageScope|>
  <MessageScope>
    <:welcome>
      <WelcomeComponent />
    </:welcome>
  </MessageScope>
</I18n>

Inline component in translation

translation.key: 'Welcome, <WelcomeComponent @name="Zoe" />!',
// WelcomeComponent

to Ember {{@name}} and Tomster
<I18n @i18nid="translation.key" @htmlSafe={{true}} />

Output will be

Welcome, to Ember Zoe and Tomster!

P.S Keep in mind, as it will render any html passed to it, even <script> tags. Only use that where you are 100% sure that content is safe.

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Keywords

FAQs

Last updated on 17 Nov 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc