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

Commit

Permalink
l10n implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennifer Fong committed Jan 14, 2014
1 parent 447a058 commit ea43fca
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 4 deletions.
4 changes: 3 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"angular-route": "1.2.0",
"gumhelper": "sole/gumhelper#8f344dc27605fb9ee063c911f8bd5fc47b9300b4",
"moment": "2.4.0",
"localforage": "mozilla/localForage#00c9d5f6db247a623c3e4f92a7c0e0d4ffbc8bbf"
"localforage": "mozilla/localForage#00c9d5f6db247a623c3e4f92a7c0e0d4ffbc8bbf",
"angular-translate": "1.1.1",
"angular-translate-loader-static-files": "0.1.6"
}
}
10 changes: 9 additions & 1 deletion public/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var socket = io.connect(location.protocol + '//' + location.hostname +

angular.module('chatspace', [
'ngRoute',
'pascalprecht.translate',
'chatspace.factories',
'chatspace.controllers'
]).
Expand Down Expand Up @@ -98,7 +99,14 @@ service('api', function ($http, $timeout, $rootScope) {
}
};
}).
config(function ($routeProvider, $locationProvider) {
config(function ($routeProvider, $locationProvider, $translateProvider) {
$translateProvider.useStaticFilesLoader({
prefix: '/locales/',
suffix: '.json'
});

$translateProvider.preferredLanguage('en');

$routeProvider
.when('/', {
controller: 'HomeCtrl',
Expand Down
6 changes: 5 additions & 1 deletion public/javascripts/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

angular.module('chatspace.controllers', []).
controller('AppCtrl',
function ($scope, authenticate, $rootScope, $http, $location, $routeParams, user, localCache, cameraHelper) {
function ($scope, authenticate, $rootScope, $http, $location, $routeParams, $translate, user, localCache, cameraHelper) {

user.call();
$rootScope.friendPredicate = '-username';
Expand All @@ -13,6 +13,10 @@ angular.module('chatspace.controllers', []).
$rootScope.showCamera = false;
$rootScope.showFollowing = false;

$rootScope.language = window.navigator.userLanguage || window.navigator.language || 'en';

$translate.uses($rootScope.language);

socket.on('friend', function (data) {
$rootScope.$apply(function () {
$rootScope.friends[data.friend.userHash] = {
Expand Down
4 changes: 4 additions & 0 deletions public/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"CHATSPACES": "Chatspaces",
"FOO": "This is a paragraph"
}
Empty file added public/locales/es.json
Empty file.
4 changes: 4 additions & 0 deletions public/locales/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"CHATSPACES": "Chatspaces2",
"FOO": "This is a paragraph"
}
4 changes: 3 additions & 1 deletion views/layout.jade
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
doctype html
html(ng-app='chatspace')
head
title chatspaces
title {{ 'CHATSPACES' | translate }}
meta(content='width=device-width, height=device-height, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0', name='viewport')
meta(content='yes', name='apple-mobile-web-app-capable')
base(href='/')
Expand All @@ -25,6 +25,8 @@ html(ng-app='chatspace')
script(src='/javascripts/vendor/moment/moment.js')
script(src='/javascripts/vendor/animated-gif/dist/Animated_GIF.min.js')
script(src='/javascripts/vendor/angular/angular.js')
script(src='/javascripts/vendor/angular-translate/angular-translate.js')
script(src='/javascripts/vendor/angular-translate-loader-static-files/angular-translate-loader-static-files.js')
script(src='/javascripts/vendor/angular-route/angular-route.js')
script(src='/javascripts/vendor/gumhelper/gumhelper.js')
script(src='/javascripts/lib/videoShooter.js')
Expand Down

0 comments on commit ea43fca

Please sign in to comment.