Skip to content

Commit

Permalink
Merge pull request #648 from LBKinson/448_i18n
Browse files Browse the repository at this point in the history
issue #448: utilizing ember-i18n addon
  • Loading branch information
joshsmith committed Mar 29, 2017
2 parents 3b30c8d + 1eed832 commit c227e47
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 18 deletions.
16 changes: 16 additions & 0 deletions app/locales/en-us/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Ember-I18n includes configuration for common locales. Most users
// can safely delete this file. Use it if you need to override behavior
// for a locale or define behavior for a locale that Ember-I18n
// doesn't know about.
export default {
// rtl: [true|FALSE],
//
// pluralForm: function(count) {
// if (count === 0) { return 'zero'; }
// if (count === 1) { return 'one'; }
// if (count === 2) { return 'two'; }
// if (count < 5) { return 'few'; }
// if (count >= 5) { return 'many'; }
// return 'other';
// }
};
27 changes: 27 additions & 0 deletions app/locales/en-us/translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export default {
'about-us': {
'we-help': 'We help people build simple software<br/>that solves hard problems.',
'we-were-promised': 'We were promised flying cars and we got targeted advertising.',
'where-are-the-apps': 'Where are the apps to challenge poverty or end climate change?',
'we-want-to-build': 'We want to build these things not because they are easy,<br/>but because they are hard. Here\'s our plan:',
'value-prop': {
'headers': {
'connect': 'Connect People',
'provide': 'Provide Support',
'fund': 'Fund Projects',
'develop': 'Develop New Tools'
},
'descriptions': {
'connect': 'We\'re matching developers and designers, project managers and marketers – any and every talent – to ambitious projects that need their help.',
'provide': 'We\'re educating and training, developing and encouraging people who build public software. We want to help projects be successful and people to do their best work.',
'fund': 'We\'re building a crowdfunding platform to support ongoing work. We aim to keep funders engaged in projects and connected to the teams they\'re supporting.',
'develop': 'We\'re developing tools to help people collaborate on, organize, and even distribute their work. We\'re listening closely to hear what needs built, and then building it.'
}
},
'call-to-action': {
'header': 'We need your help.',
'description': 'We\'re a small team and we can\'t do this alone.',
'button': 'Join Code Corps today'
}
}
};
26 changes: 26 additions & 0 deletions app/routes/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default Route.extend(ApplicationRouteMixin, LoadingBar, {
flashMessages: service(),
metrics: service(),
onboarding: service(),
i18n: service(),

isOnboarding: computed.alias('onboarding.isOnboarding'),
onboardingRoute: computed.alias('onboarding.routeForCurrentStep'),
Expand Down Expand Up @@ -164,6 +165,10 @@ export default Route.extend(ApplicationRouteMixin, LoadingBar, {
.catch(() => this._invalidateSession());
},

afterModel() {
this._setTranslationLocale();
},

sessionAuthenticated() {
return this._loadCurrentUser()
.then(() => {
Expand Down Expand Up @@ -221,6 +226,27 @@ export default Route.extend(ApplicationRouteMixin, LoadingBar, {
return get(this, 'currentUser').loadCurrentUser();
},

_setTranslationLocale() {

let locales = this.get('i18n.locales');

if (navigator.languages) {
if (navigator.languages[0]) {
if (locales.includes(navigator.languages[0].toLowerCase())) {
return this.set('i18n.locale', navigator.languages[0].toLowerCase());
} else {
this.set('i18n.locale', 'en-us');
}
} else {
this.set('i18n.locale', 'en-us');
}
} else if (locales.includes(navigator.language.toLowerCase())) {
this.set('i18n.locale', navigator.language.toLowerCase());
} else {
this.set('i18n.locale', 'en-us');
}
},

// If the user is still in the process of onboarding, they are allowd to visit
// only select routes. Trying to access any other route redirects them to
// their next onboarding route.
Expand Down
30 changes: 15 additions & 15 deletions app/templates/about.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@

<div class="container">
<div class="about-us">
<h2>We help people build simple software<br/>that solves hard problems.</h2>
<h2>{{t 'about-us.we-help'}}</h2>
<div class="airplane-icon-container">
<div class="airplane-icon"></div>
</div>
<h3>We were promised flying cars and we got targeted advertising.</h3>
<h3>{{t 'about-us.we-were-promised'}}</h3>
<div class="cars-icon"></div>
<h3>Where are the apps to challenge poverty or end climate change?</h3>
<h3>{{t 'about-us.where-are-the-apps'}}</h3>
<div class="rocketship-icon"></div>
<h3>We want to build these things not because they are easy,<br/>but because they are hard. Here's our plan:</h3>
<h3>{{t 'about-us.we-want-to-build'}}</h3>
<ul>
<li class="step">
<div class="connect-icon"></div>
<h4>Connect People</h4>
<p>We're matching developers and designers, project managers and marketers – any and every talent – to ambitious projects that need their help.</p>
<h4>{{t 'about-us.value-prop.headers.connect'}}</h4>
<p>{{t 'about-us.value-prop.descriptions.connect'}}</p>
</li>
<li class="step">
<div class="support-icon"></div>
<h4>Provide Support</h4>
<p>We're educating and training, developing and encouraging people who build public software. We want to help projects be successful and people to do their best work.</p>
<h4>{{t 'about-us.value-prop.headers.provide'}}</h4>
<p>{{t 'about-us.value-prop.descriptions.provide'}}</p>
</li>
<li class="step">
<div class="fund-icon"></div>
<h4>Fund Projects</h4>
<p>We're building a crowdfunding platform to support ongoing work. We aim to keep funders engaged in projects and connected to the teams they're supporting.</p>
<h4>{{t 'about-us.value-prop.headers.fund'}}</h4>
<p>{{t 'about-us.value-prop.descriptions.fund'}}</p>
</li>
<li class="step">
<div class="develop-icon"></div>
<h4>Develop New Tools</h4>
<p>We're developing tools to help people collaborate on, organize, and even distribute their work. We're listening closely to hear what needs built, and then building it.</p>
<h4>{{t 'about-us.value-prop.headers.develop'}}</h4>
<p>{{t 'about-us.value-prop.descriptions.develop'}}</p>
</li>
</ul>
<div class="help">
<h3>We need your help.</h3>
<p>We're a small team and we can't do this alone.</p>
<p>{{#link-to "signup" class="button default"}}Join Code Corps today{{/link-to}}</p>
<h3>{{t 'about-us.call-to-action.header'}}</h3>
<p>{{t 'about-us.call-to-action.description'}}</p>
<p>{{#link-to "signup" class="button default"}}{{t 'about-us.call-to-action.button'}}{{/link-to}}</p>
</div>
</div>
</div>
11 changes: 8 additions & 3 deletions docs/INSTALLING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,18 @@ npm ERR! and the repository exists.
you will need to [associate your ssh key with github](https://help.github.com/articles/generating-an-ssh-key/)

## Verify it worked
Run `ember server`

Point your browser (or make a direct request) to `http://localhost:4200`. You should see the code corps website.
Start your server:

```shell
ember serve
```

Now point your browser (or make a direct request) to `http://localhost:4200`. You should see the Code Corps website!

### Next steps

Now that you're set up, you should [read more about how to develop with the API](USAGE.md).
Now that you're set up, you should [read more about how to use the app](USAGE.md).

## Issues installing?

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"ember-dragula": "1.9.3",
"ember-exam": "0.6.1",
"ember-export-application-global": "^2.0.0",
"ember-i18n": "4.3.2",
"ember-keyboard": "^2.1.9",
"ember-load-initializers": "^0.6.0",
"ember-metrics": "0.10.0",
Expand Down
1 change: 1 addition & 0 deletions tests/unit/routes/application-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ moduleFor('route:application', 'Unit | Route | application', {
needs: [
'service:current-user',
'service:flash-messages',
'service:i18n',
'service:loading-bar',
'service:metrics',
'service:onboarding',
Expand Down
9 changes: 9 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3054,6 +3054,15 @@ ember-hash-helper-polyfill@^0.1.1:
ember-cli-babel "^5.1.7"
ember-cli-version-checker "^1.2.0"

ember-i18n@4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/ember-i18n/-/ember-i18n-4.3.2.tgz#8a0374ce0815045f47698304450e7cf0497b3a5f"
dependencies:
broccoli-funnel "^1.0.6"
ember-cli-babel "^5.0.0"
ember-cli-version-checker "^1.1.6"
ember-getowner-polyfill "^1.0.0"

ember-inflector@^1.9.2, ember-inflector@^1.9.4:
version "1.11.0"
resolved "https://registry.yarnpkg.com/ember-inflector/-/ember-inflector-1.11.0.tgz#99baae18e2bee53cfa97d8db1d739280289a174f"
Expand Down

0 comments on commit c227e47

Please sign in to comment.