New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ember-cli-foreigner

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-foreigner

`ember-cli-foreigner` is a set of helpers and mixins to interface with the [foreigner.js](https://github.com/mirego/foreigner.js) library in Ember.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

ember-cli-foreigner

ember-cli-foreigner is a set of helpers and mixins to interface with the foreigner.js library in Ember.

Node package version Travis-CI status Code Climate

Setup

npm install ember-cli-foreigner --save-dev
ember g ember-cli-foreigner

Adding a locale

ember g locale <locale>

In your app’s config/environment.js, set the default locale:

var ENV = {
  APP: {
    defaultLocale: '<locale>'
  }
};

Changing the locales folder

You can change the folder where the translations are put by setting the locale prefix:

var ENV = {
  modulePrefix: 'your-app',
  localePrefix: 'your-app/localizations'
};

The path is relative to modulePrefix and is set to locales by default.

Usage

To see how to write your locale file, see the foreigner.js README

Translating text content

{{!-- Simple translation --}}
<h1>{{t 'hello_world'}}</h1>

{{!-- Bound interpolated values --}}
<p>{{t 'you_have_x_message' messageCount=messages.length}}</p>

Translating attributes of an Ember helper

Say you want to translate the placeholder attribute on the input helper.

Since 1.0.0
{{input placeholder=(t 'form.input_placeholder')}}
Versions prior to 1.0.0

First, you have to include the translateable-attributes mixin on the Ember.TextField class:

import TranslateableAttributes from 'ember-cli-foreigner/translateable-attributes';

Ember.TextField.reopen(TranslateableAttributes);

And then you can define your placeholder like this:

{{input placeholderTranslation='form.input_placeholder'}}

Changing the locale

The locale property is set on your app’s instance, so to change it you could do something like this in your routes/application.js:

export default Ember.Route.extend({
  actions: {
    changeLocale: function(locale) {
      var application = this.container.lookup('application:main');
      application.set('locale', locale);

      // Transitioning to any other route from here should render
      // your templates with the new locale’s translations
    }
  }
});

Contributing

Installation

  • git clone this repository
  • npm install
  • bower install

Running

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

License

ember-cli-foreigner is © 2014-2015 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.

Keywords

FAQs

Package last updated on 27 May 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc