Skip to content
This repository has been archived by the owner on Mar 1, 2021. It is now read-only.

Commit

Permalink
init i18n support for French - fix #129
Browse files Browse the repository at this point in the history
  • Loading branch information
clemsos committed Aug 11, 2016
1 parent 658ed54 commit 6e7ef51
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 9 deletions.
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ practicalmeteor:mocha
xolvio:cleaner
practicalmeteor:chai
kadira:blaze-layout
tap:i18n
5 changes: 5 additions & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
accounts-base@1.2.8
accounts-password@1.1.11
aldeed:simple-schema@1.3.3
aldeed:tabular@1.4.1
allow-deny@1.0.5
autoupdate@1.2.10
Expand All @@ -17,6 +18,7 @@ boilerplate-generator@1.0.9
caching-compiler@1.0.5_1
caching-html-compiler@1.0.6
callback-hook@1.0.9
cfs:http-methods@0.0.32
check@1.2.3
coffeescript@1.1.2_1
dburles:mongo-collection-instances@0.3.5
Expand Down Expand Up @@ -53,6 +55,7 @@ logging@1.0.13_1
materialize:materialize@0.97.6
meteor@1.1.15_1
meteor-base@1.0.4
meteorspark:util@0.2.0
mikowals:batch-insert@1.1.13
minifier-css@1.1.12_1
minifier-js@1.1.12_1
Expand All @@ -74,6 +77,7 @@ practicalmeteor:mocha@2.4.5_4
practicalmeteor:mocha-core@1.0.0
practicalmeteor:sinon@1.14.1_2
promise@0.7.2_1
raix:eventemitter@0.1.3
raix:handlebar-helpers@0.2.5
random@1.0.10
rate-limit@1.0.5
Expand All @@ -94,6 +98,7 @@ spacebars-compiler@1.0.12
srp@1.0.9
standard-minifier-css@1.0.7_1
standard-minifier-js@1.0.7_1
tap:i18n@1.8.2
templating@1.1.12_1
templating-tools@1.0.4
tmeasday:test-reporter-helpers@0.2.1
Expand Down
14 changes: 14 additions & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"topogram_view": {
"searchbox": "Lookup a node"
},
"filter" : {
"default" : "Choose from type",
"title" : "Filter",
"byDegree" : "Filter by degree",
"clear" : "Clear"
},
"infobox": {
"group" : "group"
}
}
14 changes: 14 additions & 0 deletions i18n/fr.i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"topogram_view": {
"searchbox": "Chercher un node"
},
"filter" : {
"default" : "Choix du groupe",
"title" : "Filtrer",
"byDegree" : "Filtrer par degré",
"clear" : "Réinitialiser"
},
"infobox": {
"group" : "Groupe"
}
}
21 changes: 21 additions & 0 deletions imports/startup/client/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { TAPi18n } from 'meteor/tap:i18n'


const localeFromBrowser = window.navigator.userLanguage || window.navigator.language;

switchToLocale()

// TODO : remove ugly and unreliable timeout...
setTimeout(switchToLocale,1000);

function switchToLocale() {

// Setup language, try setting by browser (default en)
let locale = 'en';

if (localeFromBrowser.match(/en/)) locale = 'en'
if (localeFromBrowser.match(/fr/)) locale = 'fr'

locale = 'fr'
TAPi18n.setLanguage(locale)
}
1 change: 0 additions & 1 deletion imports/startup/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Template } from 'meteor/templating'
import * as _ from 'lodash'

// register helpers

Template.registerHelper( 'objectToPairs', function( object ) {
return _.map( object, function( value, key ) {
return {
Expand Down
7 changes: 5 additions & 2 deletions imports/startup/client/routes/topograms.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Router } from 'meteor/kadira:flow-router'
import { Meteor } from 'meteor/meteor'
import { FlowRouter } from 'meteor/kadira:flow-router'
import { AccountsTemplates } from 'meteor/useraccounts:core'
import { BlazeLayout } from 'meteor/kadira:blaze-layout';

// translations
import '../i18n.js'

// Import to load these templates and layout
import '../../../ui/layouts/mainLayout.js'
Expand Down
2 changes: 1 addition & 1 deletion imports/ui/components/boxes/filterBox/filterBox.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
<div class="row">
<div class="col s12">
<a href="#" class="btn btn-xs clear-filters">Clear</a>
<a href="#" class="btn btn-xs clear-filters">{{_ 'filter.clear'}}</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{# if $gt categories.length 1 }}
<div class="input-field col s12 filterByCategory">
<select name="categoryFilterType" class="filterByCategory{{this.type}}" multiple>
<option value="" disabled >Choose from types</option>
<option value="" disabled >{{_ 'filter.default' }}</option>
{{#each categories}}
<option value="{{this.name}}">
<svg data-category="{{this.name}}" height="10" width="10">
Expand All @@ -12,7 +12,7 @@
</option>
{{/each}}
</select>
<label for="categoryFilterType">Filter {{type}}</label>
<label for="categoryFilterType">{{_ 'filter.title' }} {{type}}</label>
</div>
{{/ if}}
</template>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<template name="filterByDegree">
<label for="filterByDegree">Filter By Degree ({{maxMinSlider}})</label>
<label for="filterByDegree">{{_ 'filter.byDegree' }} ({{maxMinSlider}})</label>
<div id="filterByDegree" name="filterByDegree"></div>
</template>
2 changes: 1 addition & 1 deletion imports/ui/components/boxes/infoBox/infoBox.readOnly.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</li>
{{#if currentSelection.data.group }}
<li class="collection-item">
<span class="badge">Group</span> {{ currentSelection.data.group }}
<span class="badge">{{_ 'infobox.group'}}</span> {{ currentSelection.data.group }}
</li>
{{/if}}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion imports/ui/pages/topograms/topograms-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>
</div>
</div>

{{> searchBox network=networkInstance searchName="mainSearch" type="source" placeholder="Lookup a node"}}
{{> searchBox network=networkInstance searchName="mainSearch" type="source" placeholder=placeholder}}
{{> filterBox network=networkInstance }}
</div>
<div class="col offset-s6 s3">
Expand Down
5 changes: 5 additions & 0 deletions imports/ui/pages/topograms/topograms-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Template } from 'meteor/templating'
import { ReactiveVar } from 'meteor/reactive-var'
import { FlowRouter } from 'meteor/kadira:flow-router'
import { Meteor } from 'meteor/meteor'
import { TAPi18n } from 'meteor/tap:i18n';

import { Topograms } from '../../../api/collections.js'

import '../../components/boxes/infoBox/infoBox.readOnly.js'
Expand Down Expand Up @@ -30,6 +32,9 @@ Template.topogramView.onCreated( function() {
})

Template.topogramView.helpers({
placeholder : function() {
return TAPi18n.__('topogram_view.searchbox')
},
networkInstance : function(){
return Template.instance().network
},
Expand Down

0 comments on commit 6e7ef51

Please sign in to comment.