Skip to content

Commit

Permalink
Translating the admin panel for PoC
Browse files Browse the repository at this point in the history
* first time playing with ember-intl (part of format.js). using the 2.0 (beta) version to try side-loading of messages
* installing grunt-plugin for downloading translated strings
* removing old translation files
* `grunt dev` will also download the translation files
  • Loading branch information
morficus committed May 26, 2015
1 parent efe3b5e commit 4a0c574
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 26 deletions.
16 changes: 16 additions & 0 deletions Gruntfile.js
Expand Up @@ -446,6 +446,19 @@ var _ = require('lodash'),
params: '--init'
}
}
},

// ### transifex_keyvaluejson
// download translation strings from Transifex
transifex_keyvaluejson: {
admin: {
options: {
project: 'ghost-test-project',
resource: 'ghost-admin-poc',
dest: '/core/client/translations'
}
}

}
};

Expand Down Expand Up @@ -878,6 +891,9 @@ var _ = require('lodash'),
grunt.registerTask('init', 'Prepare the project for development',
['shell:ember:init', 'shell:bower', 'update_submodules', 'assets', 'default']);

grunt.registerTask('i18n', 'Get translation strings for all avialble locales',
['transifex_keyvaluejson:admin']);

// ### Basic Asset Building
// Builds and moves necessary client assets. Prod additionally builds the ember app.
grunt.registerTask('assets', 'Basic asset building & moving',
Expand Down
9 changes: 8 additions & 1 deletion core/client/app/app.js
Expand Up @@ -10,7 +10,14 @@ Ember.MODEL_FACTORY_INJECTIONS = true;
var App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver: Resolver
Resolver: Resolver,
ready: function () {

var language = navigator.language || navigator.browserLanguage;
//TODO: need to figure out how to set this dynamically based on blog setting
this.intl.set('locales', [language, 'hu-HU', 'es', 'en']);

}
});

loadInitializers(App, config.modulePrefix);
Expand Down
25 changes: 25 additions & 0 deletions core/client/app/formats.js
@@ -0,0 +1,25 @@
export default {
date: {
'numeric': {
month: 'numeric',
day: 'numeric',
year: 'numeric'
},
long: {
month: 'long',
day : 'numeric',
year : 'numeric'
}
},
number: {
usd: { style: 'currency', currency: 'EUR' },
eur: { style: 'currency', currency: 'USD' }
},
time: {
hhmmss: {
hour: 'numeric',
minute: 'numeric',
second: 'numeric'
}
}
};
15 changes: 15 additions & 0 deletions core/client/app/locales/en.js
@@ -0,0 +1,15 @@
import Locale from 'ember-intl/models/locale';

export default Locale.extend({
locale: 'en',
messages: {
greeting: 'hello!',
num: 99,
product: {
info: '{product} will cost {price, number, EUR} if ordered by {deadline, date, time}',
html: {
info: '<strong>{product}</strong> will cost <em>{price, number, EUR}</em> if ordered by {deadline, date, time}'
}
}
}
});
12 changes: 12 additions & 0 deletions core/client/app/locales/es.js
@@ -0,0 +1,12 @@
import Locale from 'ember-intl/models/locale';

export default Locale.extend({
locale: 'es',
messages: {
greeting: 'hola!',
num: 99,
product: {
info: '{product} va a costar {price, number USD} si es ordenado antes del {deadline, date, time}'
}
}
});
14 changes: 7 additions & 7 deletions core/client/app/templates/-navbar.hbs
@@ -1,20 +1,20 @@
<nav class="global-nav" role="navigation">

<a class="nav-item ghost-logo" href="{{gh-path 'blog'}}" title="Visit blog">
<div class="nav-label"><i class="icon-ghost"></i> <span>Visit blog</span> </div>
<a class="nav-item ghost-logo" href="{{gh-path 'blog'}}" title="{{format-message (intl-get "navigation.visitBlog")}}">
<div class="nav-label"><i class="icon-ghost"></i> <span>{{format-message (intl-get "navigation.visitBlog")}}</span> </div>
</a>

{{#link-to "posts" classNames="nav-item nav-content js-nav-item"}}
<div class="nav-label"><i class="icon-content"></i> Content</div>
<div class="nav-label"><i class="icon-content"></i> {{format-message (intl-get "navigation.content")}}</div>
{{/link-to}}

{{#link-to "editor.new" classNames="nav-item nav-new js-nav-item"}}
<div class="nav-label"><i class="icon-add"></i> New Post</div>
<div class="nav-label"><i class="icon-add"></i> {{format-message (intl-get "navigation.newPost")}}</div>
{{/link-to}}

{{#unless session.user.isAuthor}}
{{#link-to "settings" classNames="nav-item nav-settings js-nav-item"}}
<div class="nav-label"><i class="icon-settings2"></i> Settings</div>
<div class="nav-label"><i class="icon-settings2"></i> {{format-message (intl-get "navigation.settings")}}</div>
{{/link-to}}
{{/unless}}

Expand All @@ -41,9 +41,9 @@
{{/gh-dropdown-button}}
{{#gh-dropdown tagName="div" classNames="dropdown" name="user-menu" closeOnClick="true"}}
<ul class="dropdown-menu dropdown-triangle-top-right js-user-menu-dropdown-menu" role="menu">
<li role="presentation">{{#link-to "settings.users.user" session.user.slug classNames="dropdown-item user-menu-profile js-nav-item" role="menuitem" tabindex="-1"}}<i class="icon-user"></i> Your Profile{{/link-to}}</li>
<li role="presentation">{{#link-to "settings.users.user" session.user.slug classNames="dropdown-item user-menu-profile js-nav-item" role="menuitem" tabindex="-1"}}<i class="icon-user"></i> {{format-message (intl-get "navigation.yourProfile")}}{{/link-to}}</li>
<li class="divider"></li>
<li role="presentation">{{#link-to "signout" classNames="dropdown-item user-menu-signout" role="menuitem" tabindex="-1"}}<i class="icon-power"></i> Sign Out{{/link-to}}</li>
<li role="presentation">{{#link-to "signout" classNames="dropdown-item user-menu-signout" role="menuitem" tabindex="-1"}}<i class="icon-power"></i> {{format-message (intl-get "navigation.signOut")}}{{/link-to}}</li>
</ul>
{{/gh-dropdown}}
</div>{{! .user-menu }}
Expand Down
48 changes: 31 additions & 17 deletions core/client/app/templates/settings/about.hbs
@@ -1,6 +1,6 @@
<header class="settings-view-header">
{{#link-to "settings" class="btn btn-default btn-back"}}Back{{/link-to}}
<h2 class="page-title">About</h2>
{{#link-to "settings" class="btn btn-default btn-back"}}{{format-message (intl-get "common.back")}}{{/link-to}}
<h2 class="page-title">{{format-message (intl-get "settings.about.title")}}</h2>
</header>

<section class="content settings-about">
Expand All @@ -11,41 +11,55 @@
</span>
<span class="version blue">v{{model.version}}</span>
</h1>
{{gh-notifications location="settings-about-upgrade" notify="updateNotificationChange"}}
{{#unless updateNotificationCount}}
<p>A free, open, simple publishing platform</p>
{{/unless}}

{{gh-notifications location="settings-about-upgrade" notify="updateNotificationChange"}}
{{#unless updateNotificationCount}}
<p>{{format-message (intl-get "common.slogan")}}</p>
{{/unless}}

<p>
<strong>This is a pluralization sample: </strong>{{format-message (intl-get "pluralSample") numPost=8 currentDate=1430700266792 }}
</p>
<div class="about-environment-help clearfix">
<div class="about-environment">
<dl>
<dt>Version:</dt>
<dt>{{format-message (intl-get "settings.about.version")}}:</dt>
<dd class="about-environment-detail">{{model.version}}</dd>
<dt>Environment:</dt>
<dt>{{format-message (intl-get "settings.about.environment")}}:</dt>
<dd class="about-environment-detail">{{model.environment}}</dd>
<dt>Database:</dt>
<dt>{{format-message (intl-get "settings.about.database")}}:</dt>
<dd class="about-environment-detail about-environment-database">{{model.database}}</dd>
<dt>Mail:</dt>
<dd class="about-environment-detail">{{#if model.mail}}{{model.mail}}{{else}}Native{{/if}}</dd>
<dt>{{format-message (intl-get "settings.about.mail")}}:</dt>
<dd class="about-environment-detail">{{#if model.mail}}{{model.mail}}{{else}}{{format-message (intl-get "settings.about.native")}}{{/if}}</dd>
</dl>
</div>
<div class="about-help">
<a href="http://support.ghost.org" class="btn">User Documentation</a>
<a href="https://ghost.org/slack/" class="btn">Get Help With Ghost</a>

<a href="http://support.ghost.org" class="btn">
{{format-message (intl-get "settings.about.userDocumentation")}}
</a>
<a href="https://ghost.org/forum/" class="btn">
{{format-message (intl-get "settings.about.getHelp")}}
</a>

</div>
</div>
</section>

<section class="about-credits">
<h1>The People Who Made it Possible</h1>
<h1>{{format-message (intl-get "settings.about.thePeople" name="Maurice")}}</h1>

<ul class="top-contributors clearfix">
{{partial "contributors"}}
{{ partial "contributors" }}
</ul>

<p class="about-contributors-info">Ghost is built by an incredible group of contributors from all over the world. Here are just a few of the people who helped create the version you’re using right now.</p>
<p class="about-contributors-info">
{{format-message (intl-get "settings.about.incredibleGroupOfContributors")}}
</p>

<a href="https://ghost.org/about/contribute/" class="about-get-involved btn-blue btn-lg btn">Find out how you can get involved</a>
<a href="https://ghost.org/about/contribute/" class="about-get-involved btn-blue btn-lg btn">
{{format-message (intl-get "settings.about.howToGetInvolved")}}
</a>

<p class="about-copyright">
Copyright 2013 - 2015 Ghost Foundation, released under the <a href="https://github.com/TryGhost/Ghost/blob/master/LICENSE">MIT license</a>.
Expand Down
3 changes: 2 additions & 1 deletion core/client/app/templates/settings/general.hbs
Expand Up @@ -2,7 +2,8 @@
{{#link-to "settings" class="btn btn-default btn-back"}}Back{{/link-to}}
<h2 class="page-title">General</h2>
<section class="page-actions">
<button type="button" class="btn btn-blue" {{action "save"}}>Save</button>
<button type="button" class="btn btn-blue" {{action "save"}}>Save
</button>
</section>
</header>

Expand Down
1 change: 1 addition & 0 deletions core/client/package.json
Expand Up @@ -34,6 +34,7 @@
"ember-cli-uglify": "1.0.1",
"ember-data": "1.0.0-beta.16.1",
"ember-export-application-global": "^1.0.2",
"ember-intl": "https://github.com/yahoo/ember-intl.git#2.0",
"fs-extra": "0.16.3",
"glob": "^4.0.5"
},
Expand Down
30 changes: 30 additions & 0 deletions core/client/translations/en.json
@@ -0,0 +1,30 @@
{
"common": {
"slogan": "A free, open, simple publishing platform",
"back": "Back"
},
"navigation": {
"visitBlog": "Visit blog",
"content": "Content",
"newPost": "New Post",
"settings": "Settings",
"yourProfile": "Your Profile",
"signOut": "Sign Out"
},
"pluralSample": "As of {currentDate, date, long} there are {numPost, plural, =0 {no posts} =1 {post} other {# posts} } avilable in this blog.",
"settings": {
"about": {
"title": "About",
"version": "Version",
"environment": "Environment",
"database": "Database",
"mail": "Mail",
"native": "Native",
"userDocumentation": "User Documentation",
"getHelp": "Get Help With Ghost",
"thePeople": "The People Who Made it Possible",
"incredibleGroupOfContributors": "Ghost is built by an incredible group of contributors from all over the world. Here are just a few of the people who helped create the version you’re using right now.",
"howToGetInvolved": "Find out how you can get involved"
}
}
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -89,6 +89,7 @@
"grunt-mocha-cli": "~1.13.0",
"grunt-mocha-istanbul": "2.4.0",
"grunt-shell": "~1.1.1",
"grunt-transifex-keyvaluejson": "0.0.2",
"grunt-update-submodules": "~0.4.1",
"matchdep": "~0.3.0",
"nock": "0.52.4",
Expand Down

0 comments on commit 4a0c574

Please sign in to comment.