Giter VIP home page Giter VIP logo

ember-i18n's Introduction

Ember-I18n - Internationalization for Ember

This library has been deprecated in favor of ember-intl. This repository will stay open until at least 2019-12-31. If you find security-related issues with released versions, please contact a maintainer directly, or, if that fails, open an issue.

ember-i18n's People

Contributors

blimmer avatar chrmod avatar cibernox avatar danshapir avatar digitalcora avatar ebryn avatar f3ndot avatar jamesarosen avatar jasonmit avatar jipiboily avatar jish avatar karellm avatar karl-sjogren avatar locks avatar luqman avatar mehulkar avatar mphasize avatar nathanhammond avatar opichals avatar owilliams avatar patrickberkeley avatar pjmorse avatar rapheld avatar rwjblue avatar sandstrom avatar snewcomer avatar swquinn avatar tbartelmess avatar toranb avatar victorsavu3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-i18n's Issues

translateAttr should support bound interpolations

For example:

Em.I18n.translations = {
  "link": "text/{{App.path}}/link"
};
App.path = "path1";
<a {{ translateAttr href="link" }}></a>

Would result:

<a href="text/path1/link"></a>

I think this is useful for binding property with emblem.js as I faced problem that cannot provide variable to translateAttr. i.e. :

{{t link pathBinding=App.path}}  // Works
<a {{ translateAttr href="link" pathBinding=App.path }}></a>  // Doesn't work

translations on computed property of an object

I am unable to figure out how to use translations with a computed property.

An example:

someProperty: function () {
    if (this.get('some_other_property')) {
      return 'lorem ipsum ' + this.get('some_other_property') + '  lorem ipsum';
    }
    else {
      return 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.';
    }
}.property('some_other_property'),

Any help would be greatly appreciated.

Em.I18n.translations object doesn't seem extendable

Em.I18n.translations = {
  setup: {
    'title': {
      'header': 'Some text',
      'subheader': 'More Text.'
    }
  }
};

// Extend setup object. This can in theory reside in a separate
// file but for the sake of this example is in this file itself
Em.I18n.translations.setup.offers = {
  'title': 'offer title here',
  'option': {
    'label': 'soem more text here',
  }
};

In my handlebars where I look these up:

  <h5 class="title">{{t setup.title.header}}</h5> <!-- This is perfectly resolved -->
  <div class="descriptor">
    {{t setup.title.subheader}}
  </div>
  <h5 class="title">{{t setup.offers.title}}</h5> <!-- This doesn't resolve -->

Why is the setup.offers.title doesn't resolve? If I write it in the same object, then it does. This is very weird.

view.$('#'+elementID) can be undefined

I've recently run into a case where view rendering crashed due to the way ember-i18n observed a binding. My console showed a "elem is undefined" error, referring to the result of the view.$('#'+elementID) call in the observer function. As it turns out, when this happened the view was just being destroyed, and invokeForState with '$' apparently returns undefined in this case.

This might actually be an ember issue (I'm using ember-latest commit 50de50e at the time of this writing) and not an ember-i18n issue, so I'll look into that some more. In any case I'm posting it here because fixing it for the latter is simple; check if elem is defined before checking elem.length.

Exception raised if interpolation missing

Given

SC.I18n.translations = {
  'foo.bar' = "Foo's Bar {{bar}}"
};

Trying to evaluate the translation with a missing attribute raises an exception:

SC.I18n.t('foo.bar', { bar: undefined }); // BOOM!

This is particularly frustrating when using bound interpolations, since they can become undefined when any piece of the chain is removed.

bpm compatible packaging?

James, nice code and eager to work with it.

Have you looked @ making a bpm package for this?

It looks like the coffee script wrapper prevents it from being executed when spade.required - not entirely sure.

I just included it for now in my source, but it would be nice to push this as a bpm package.

The wrapping <span>

i18n wraps around the translated text in a or a tagName specified by developer. This span can potentially match a css rule and alter the original intended styling on the text. I actually hit. Is this a known issue?

In this particular case, I made adjustment to the css rule to get around. But wonder if there's better solutions. Thanks.

Re-render triggered unnecessarily

Sometimes the line elem = view.$ "##{elementID}" triggers a re-render, which is deprecated (see below). This happens if the view is still in the buffer (view.get('state') == 'inBuffer').

I've tried to figure out exactly how to solve this, but haven't been able to. It says the implementation borrows heavily from the bindAttr helper, so perhaps we can look at how that code has changed (since Ember.I18n was written).

DEPRECATION: Something you did caused a view to re-render after it rendered but before it was inserted into the DOM. Because this is avoidable and the cause of significant performance issues in applications, this behavior is deprecated. If you want to use the debugger to find out what caused this, you can set ENV.RAISE_ON_DEPRECATION to true.

no license info?

I am very interested in this project, since I18N support has not yet been added to SC2 by the SproutCore team.

However, I cannot find any license info, so I do not know if I can legally use this in my application.

Would you mind adding a license file in the top of your repository? If you don't care what kind of licensing you use, I'd vote for MIT or BSD-style licensing, as these are nonrestrictive.

Thanks!

Don't expose CLDR.defaultLocale

See #46

If the CLDR pluralization rules are bundled with this repository, we shouldn't expose CLDR.defaultLocale. @heartsentwined did this in #44 by introducing Ember.I18n.Config.locale. I might prefer Ember.I18n.locale or Ember.I18n.config.locale, but the idea of hiding this dependency seems good.

Default count value

With some translation systems† there won't be any translation on the "naked" key (e.g. my.translation.key) and one must specify a pluralization, such as one or other.

E.g. the translation data will look like this:

{ my: { translation: { key: { one: "cat", many: "cats" } } } }

and lookups on my.translation.key would simply return the pluralization data, not a generic "cat" translation. In this particular case it would be nice if count always had a default value, e.g. 0 or 1.

I know that with the Em.I18n structure on the translation data (non-nested hash with key-value pairs) it's possible to keep a translation on the suffix-less key, but that isn't possible with all underlying translation structures (e.g. YAML files or JSON structures).

What are your thoughts on this?

http://guides.rubyonrails.org/i18n.html#pluralization

Using property as translation key, plus scoping

Currently the {{t}} helper is passed a string key, I've recently had the need to translate based on the value of a property (in this case order).

For now I've just added a property on the controller for translatedOrder:

translatedOrder: function(){
    var order = this.get("order");
    return Ember.I18n.t("buttons.order."+order");
}.property("order")

That works fine, but nicer would be something like:

{{t order scope="buttons.order"}}

Obviously we'd then need to differentiate between property keys and string keys...

We could require that string keys are quoted, but that's not very backwards compatible and extra typing for the common case.

We could use a different helper for property translations? {{pt order}} or something better!

What do people think?

Handlebars Compile requirement

I am not that familiar with coffeescript so i couldn't figure it out by reading the code.

Why is Handlebars.Compile used? Kind of forces me to include the whole handlebars.js instead of just the runtime. Can we use pre-compilation?

Maybe i am missing something pretty obvious.

Note: There is no way to ask questions in github

Support for ids in interpoloated values so we don't have to use bindings

Just like you can with Ember.View and Ember.Component, it would be nice to be able skip writing `Binding" when using interpolated values.

Example

{{t some.module.greeting nameBinding="firstName"}}

Becomes

{{t some.module.greeting name=firstName}}

I can send a PR if you agree that other people would like this feature too?

Is there a way to pass translation to component

I have a component that i want to pass translation as a property. Is there a way to do that, other than creating a property in the controller?

{{content-editable placeholder="post.text.placeholder"}}

Should translatable attributes go into the DOM automatically?

If I have something like:

// I18n Setup
Em.I18n.Translations = { blah: "diddy" };

// In a template
{{view MyView nameTranslation="blah"}}

I'm going to end up with markup like:

<div class="ember-view" name="diddy">some content...</div>

But what if I want to use the translated attribute to populate the div's content? I don't want that getting serialized into my HTML, but from what I could see in the code, it will since it ends in Translation.

Is there a way around this currently?

Make I18n.compile unnecessary

If an application wants to precompile all translations and ship those down to the client, I18n.compile should be unnecessary. Currently, it's used for missing translations:

I18n.compile("Missing translation: " + key);

We should precompile that template and return a version that's bound to the missing key.

Support recursive translations

Currently, to use a translation as the interpolation value of another translation, you have to do it in JavaScript:

errorMessage: function() {
  return Ember.I18n.t('error_message', {
    modelName: Ember.I18n.t('user')
  }
}.property().cacheable();

It would be really nice to be able to do that in the template. Perhaps a syntax like

{{t error_message modelNameTranslation="user"}}

@heartsentwined did this in #44. I'd like to port this to the current version.

CLDR.defaultLanguage

You mention in the README.md the CLDR.defaultLocale, but it is (now?) called CLDR.defaultLanguage

Translating prompt of Ember.Select

First of all, a big thank you to James for your brilliant work.

My question is about the prompt attribute of Ember.Select. I have tried the following:

{{view Ember.Select optionLabelPath="content.data.name" optionValuePath="content.data.value" promptTranslation="some.translation.in.german"}}

and defined,

Ember.Select.reopen.call(Ember.Select, Ember.I18n.TranslateableAttributes);

However, the resulting dropdown has an empty on the top, hence no prompt is displayed. Is "prompt" not translateable by ember-i18n?

Thanks.

current locale setting

I've read the docs and did not found how to set a current locale. Do I have to do something like:
Ember.i18n.translations = {
'en': {...},
'de': {...}
};
and then call them as {{t en.{...}} ? Is there a way to specify current locale to avoid that?

Access Translations From Within Another Helper

I have this custom helper method:

Ember.Handlebars.helper 'noneGiven', (attribute) ->
  if attribute == null
    t shared.none_given
  else
    attribute

Unfortunately, the helper doesn't have access to other helpers, such as your t helper. Is there a way to access it here?

Nested declaration of translations

Instead of declaring the translations like this:

Ember.I18n.translations = {
  'general.email': 'email'
  'general.givenName': 'First name'
}

I use:

Ember.I18n.translations = {
  general: {
    email: 'email'
    givenName: 'First name'
  }
}

And it apparently works. Is this offically supported? If not: Could you support it officially and mention it in the README.md?

Tests don't run by default

It looks like the version of ember in bower no longer exists. I tried upgrading the the version to v1-pre4 in the components.json file but the test suite is failing. I'm not sure which version you want to target with this repo.

Feature Request: allow interpolation of current context

I'd like to see the ability to to:

{{#collection  contentBinding="Simplifi.Dashboard.FITListController" class="goal-list small"}}
  {{t MyI18nKey}}
{{/collection}}

where MyI18nKey="{{content.someProperty}}

currently in SC2 "content", "itemView" etc are available in the current context.

it seems like evaluating SC.getPath with the current context (around line 57) e.g.

currentValue = SC.getPath(context,bindPath);

should do it. I don't have this working yet, so no patch (yet).

I've tried {{t MyI18nKey contentBinding="content"}} but that doesn't seem to get it either.

Cannot install with bower

bower cloning git://github.com/jamesarosen/ember-i18n.git
bower cached git://github.com/jamesarosen/ember-i18n.git
bower fetching ember-i18n
bower checking out ember-i18n#v1.3.2
bower warn Package ember-i18n is still using the deprecated "component.json" file
bower copying /Users/eungg.kim/.bower/cache/ember-i18n/752537e885da076f00bc4991d0dfef0a
bower cloning git://github.com/components/handlebars.js
bower cached git://github.com/components/handlebars.js
bower fetching handlebars
bower cloning git://github.com/jamesarosen/CLDR.js.git
bower cached git://github.com/jamesarosen/CLDR.js.git
bower fetching cldr
bower cloning git://github.com/components/jquery.git
bower cached git://github.com/components/jquery.git
bower fetching jquery
bower cloning git://github.com/components/ember
bower cached git://github.com/components/ember
bower fetching ember
bower checking out cldr#v1.0.1
bower copying /Users/eungg.kim/.bower/cache/cldr/9ecc1ef2122f66743d373da302425ec5
bower checking out jquery#1.7.2
bower warn Package jquery is still using the deprecated "component.json" file
bower copying /Users/eungg.kim/.bower/cache/jquery/29cb4373d29144ca260ac7c3997f4381
bower error Could not find tag satisfying: ember#~0.9.7

There were errors, here's a summary of them:
- ember Could not find tag satisfying: ember#~0.9.7
The tag ~0.9.7 could not be found within the repository

Interpolating a helper

I'm assuming this isn't possible, but I wanted to check. Is there a way to interpolate a helper, such as link-to? To do something like:

t organizations.versions.submitted userLinkBinding="#link-to 'user' user"

Update component.json

Currently the component.json declares and outdated ember version. The file should also be called bower.json now.

Double HTML encoding

When using the Ember.I18n.t function, the output is HTML encoded. This is a problem if a property that returns a result from Ember.I18n.t is bound in a template.

JS:

title: function() {
  if (this.get('state') === 'draft') {
    return Ember.I18n.t('invoice.index.title_draft', {contactName: this.get('contact.name')});
  } else {
    return Ember.I18n.t('invoice.index.title_draft', {contactName: this.get('contact.name')});
  }
}.property('state', 'contact.name')

Template:

<h1>{{title}}</h1>

Example of resulting HTML if contact.name is Billy's Billing:

<h1>Draft invoice for Billy&amp;#x27;s Billing</h1>

= The apostrophe is doubly encoded.

In my opinion, the result from Ember.I18n.t should not be HTML encoded.

Any ideas?

Expose eachTranslatedAttribute

As suggested in dockyard/ember-easyForm#99 it would be nice to have the functionality of eachTranslatedAttribute exposed.

The future of Ember-I18n

I'm opening this as an issue so we can openly discuss how Ember-I18n will work in the future. As pointed out in #34, this project has a 1.x branch to support Ember 0.9.x and a 2.0 branch to support Ember 1.x.

This morning I decided I want to make some significant changes (improvements, I hope) to Ember-I18n. Because there will be breaking changes, my recommendation is that we work on them in a separate, long-lived branch and merge it into either 2.0 if that hasn't launched yet, or a new 3.0 version if it has.

The changes include:

Consolidation

Move pluralization rules into this repository. Everyone who's doing internationalization needs pluralization. Let's make it easy. We can expose two global functions that consumers can override if they want different pluralization behavior:

  • Ember.I18n.pluralForm, which takes in a number and outputs one of [ "zero", "one", "two", "few", "many", "other" ]. This defaults to delegating to the current locale's implementation.
  • Ember.I18n.fullTranslationKey, which takes in a key ("foo.bar" or "Save"), an optional key context (useful for differentiating "Save (ticket)" from "Save (user)"), and one of the Strings from pluralForm. By default, joins them, possibly with ".".

Number Formatting

Add CLDR-compatible support for number formatting, including percentages and currencies. Add two helpers, formatNumber and unboundFormatNumber.

Time Formatting

Add support for date formatting. Add two helpers, formatDate and unboundFormatDate. Each requires only a Date. Locales define default formats. Support standard Date formatting strings as well as "ago", which renders strings like "3 minutes ago." If tagName="time" is passed, render as <time datetime="2013-02-15T08:38">15 February</time>.

Language Packs

Separate localization information into language packs. The default build will include all language packs. For those who don't support every language and want to cut down on bandwidth, add a grunt task and a Sprockets class that makes it easy to build custom Ember-I18n releases.

Oursourcing CLDR Data

Currently, the only CLDR rules that Ember-I18n consumes are the pluralization rules from CLDR.js, which are hard-coded. We can rely on node-cldr or node-closure to pull the rules from the CLDR database for us and compile the language packs.

/cc @ebryn, @rlivsey, @morten, @hjdivad, @pjmorse

Keywords aren't supported

Ember now has the concept of keywords, such as controller and view. It appears that the usage of these aren't supported within bindings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.