Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Simple ember-cli support. #149

Closed
wants to merge 1 commit into from
Closed

Conversation

chrmod
Copy link
Contributor

@chrmod chrmod commented Oct 6, 2014

It is very simple ember-cli support that uses addon mechanism.

When used in ember-cli project it:

  • provide a generator to install cldr and ember-i18n as bower components
  • imports cldr and ember-cli to application build
  • setup configuration

To use it in ember-cli project:

npm install ember-i18n --save-dev
ember generate ember-i18n

Implements issue: #129

@chrmod
Copy link
Contributor Author

chrmod commented Oct 6, 2014

What I see as a must have is a convention on where translation files should be stored within ember-cli project. Following rails way it can be config/locales. Then we need to decide how those should be imported and used inside the project. Maybe a blueprint for initializer can be helpful for some people or just a readme.

@hhff
Copy link

hhff commented Oct 8, 2014

great work @chrmod ! Personally I think the path to locales should be configured here (ember cli is all about convention over configuration) but should have the ability to be changed via environment.js

config/locales would sounds rad ideal

@givanse
Copy link

givanse commented Oct 17, 2014

👍

@jamesarosen
Copy link
Owner

Can you take a look at #156 ? If we end up dropping support for Ember 1.9+ in the Ember-I18n v2.x series, do we need to do something to the package.json here?

},

afterInstall: function() {
return this.addBowerPackageToProject('ember-i18n', '2.2.2');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be more generic so we don't have to change this every time we release a new version?

Alternatively, it might be time to write a script to bump versions everywhere.

]
}
});
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hoping to get #161 merged today. That removes the dependency on CLDR.js and adds a new lib/i18n-plurals.js. I suspect this will need to be

included: function(app) {
  this._super.included(app);

  this.app.import(app.bowerDirectory + '/ember-i18n/lib/i18n.js', {
    exports: {
      'ember-i18n': [
        'default'
      ]
    }
  });
  this.app.import(app.bowerDirectory + '/ember-i18n/lib/i18n-plurals.js');
}

(The pluralization is still an optional separate add-on, but it comes after the core I18n definition.)

},

afterInstall: function() {
return this.addBowerPackageToProject('ember-i18n');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without any version specified, bower.json will be updated to most recent one.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now it asks me to choose from:

  conflict Unable to find suitable version for ember-i18n
    1) ember-i18n 2.2.2
    2) ember-i18n ~2.9.0
[?] Answer: 1

It ignored my selected option and wrote ~2.9.0 to my bower file.

It reproduces after:

rm -rf bower_components/ember-i18n/
bower cache clean
ember generate ember-i18n

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Results:

grep ember-i18n bower.json 
"ember-i18n": "~2.9.0"

cat bower_components/ember-i18n/VERSION 
2.2.2
# bower.json disagrees

ls bower_components/ember-i18n/lib/
i18n.js
# no ember-addon/ folder :(

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tricky. What do we do with 3.0.0-beta1? Do we need to hardcode a version string in here? If so, I would prefer something like "~2" for the 2.x branch and "~3" for the 3.x branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@givanse if bower askes you to choose a version it means some of your dependencies requires different version. To make bower auto choose the your version of choice you must list it in "resolutions" property of bower.json. In the end you app will use the version it finds in bower_components.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesarosen @givanse please note that while we have addon code in ember-i18n repository, the ember-cli will use to separate copies of ember-i18n, potentially in different version.

To use ember-i18n in the application, it must be listed in bower.json as dependecy.
Next an addon code need to include this bower dependency to ember-cli build. To make it happen addon must be listed as dev-dependecy in package.json (ember-cli automatically scans all node packages for addon code).

It may happen that you will have a different version of ember-i18n in your node_modules directory then in bower_components directory. Apparantly it is the way those things are working if the addon code shares the same repository as library. We can ofcouse separate those competences, but it does not make much sense for me as ember-i18n cannot be used outside of ember.

@chrmod
Copy link
Contributor Author

chrmod commented Nov 1, 2014

@jamesarosen please take a look now

@jamesarosen
Copy link
Owner

Can you try updating this to 3.0.0-beta2? If we can get that working, I'd very much like to ship this as part of 3.0.0 :)

@chrmod
Copy link
Contributor Author

chrmod commented Dec 16, 2014

@jamesarosen Have tested this setup with 2.9.0 and current master (3.0.0-beta.2) on top of Ember 1.8 with Handlebars 1.3. Both simple translations and pluralization worked well.

EmberENV: {
FEATURES: {
I18N_COMPILE_WITHOUT_HANDLEBARS: true,
I18N_TRANSLATE_HELPER_SPAN: false
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These flags are no longer necessary.

@vire
Copy link

vire commented Feb 3, 2015

Guys, is there any update where this PR could be merged or further processed to get ember-i18n working with ember CLI?

@mjperrone
Copy link

+1

@tristanseifert
Copy link

+1

Would definitely love to see this integrated as soon as possible. Let me know how I can be of assistance!

@pjmorse
Copy link
Collaborator

pjmorse commented Feb 6, 2015

Given that there's discussion happening in the PR linked above (on Dockyard's ember-cli-i18n project) about merging/collaborating/something with an existing ember-cli-supporting project, I can see why @jamesarosen and/or @chrmod aren't pushing this forward at the moment. It sort of looks to me like this particular branch could be minimally usable if it's rebased and the extraneous configuration flags removed? I have a hack day coming at work on Monday (9 February), so I can try to get a working branch based on this then, if nobody has done it sooner.

@jamesarosen
Copy link
Owner

I'm finally working on an Ember-CLI-based project, so I may be able to pick this back up. I'd really like to get it in for v3.0.

@vire
Copy link

vire commented Feb 6, 2015

@jamesarosen 👍

Is there somethink i/we could help you with? some taks/issues etc?

@pjmorse pjmorse mentioned this pull request Feb 9, 2015
@pjmorse
Copy link
Collaborator

pjmorse commented Feb 9, 2015

I've got a fork of this branch rebased and tweaked in #192.

@mansona
Copy link

mansona commented Feb 13, 2015

So does this mean that this PR can be closed now?

@pjmorse
Copy link
Collaborator

pjmorse commented Feb 13, 2015

It's redundant with #192, but since that's not ready to merge yet either I left this open in case @chrmod wanted to pick it back up.

@chrmod
Copy link
Contributor Author

chrmod commented Feb 14, 2015

@jamesarosen please see my comments #192 (comment). The work of @pjmorse is absolutely functional as a minimal addon.

If we can improve something it is a README. It seems to me that people that want to use this addon do not feel very comoftable with ember-cli and that is why there are some many questions and misconception about how the addon is suppose to work.

Key to improve the addon is to make people use it and this will happen as soon ember-addon keyword will land in node modules registry. We can improve the addon over time, I do not see the reason to wait any longer.

PS. I've sent you an email to your zendesk inbox but received delivery error. I think we can talk this subject trough, here is my email: krzysztof(dot)modras(at)gmail(dot)com - let talk via skype or hangout, ok?

@chrmod
Copy link
Contributor Author

chrmod commented Feb 17, 2015

guess this one can be closed now

@chrmod chrmod closed this Feb 17, 2015
@chrmod chrmod deleted the ember-cli-addon branch February 17, 2015 21:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants