#214: added "angular-i18n" gem, some refactoring
This commit is contained in:
parent
1fb472d416
commit
c44b4ffda2
1
Gemfile
1
Gemfile
|
@ -62,6 +62,7 @@ gem "gemoji", "~> 1.2.1", require: 'emoji/railtie'
|
|||
gem 'angularjs-rails'
|
||||
gem 'ng-rails-csrf'
|
||||
gem 'momentjs-rails'
|
||||
gem 'angular-i18n', '0.1.1'
|
||||
|
||||
group :assets do
|
||||
gem 'sass-rails', '~> 3.2.5'
|
||||
|
|
|
@ -58,6 +58,7 @@ GEM
|
|||
json
|
||||
ancestry (1.3.0)
|
||||
activerecord (>= 2.3.14)
|
||||
angular-i18n (0.1.1)
|
||||
angularjs-rails (1.0.7)
|
||||
arel (3.0.2)
|
||||
attr_encrypted (1.2.1)
|
||||
|
@ -408,6 +409,7 @@ DEPENDENCIES
|
|||
RedCloth
|
||||
airbrake (~> 3.1.2)
|
||||
ancestry (~> 1.3.0)
|
||||
angular-i18n (= 0.1.1)
|
||||
angularjs-rails
|
||||
attr_encrypted (= 1.2.1)
|
||||
better_errors
|
||||
|
|
|
@ -1,14 +1,26 @@
|
|||
var RosaABF = angular.module('RosaABF', ['ngResource', 'ng-rails-csrf']);
|
||||
var RosaABF = angular.module('RosaABF', ['ngResource', 'ng-rails-csrf', 'angular-i18n']);
|
||||
|
||||
var DateTimeFormatter = function() {
|
||||
|
||||
var UtcFormatter = function(api_time) {
|
||||
return moment.utc(api_time * 1000).format('YYYY-MM-DD HH:mm:ss UTC');
|
||||
return moment.utc(api_time * 1000).format('YYYY-MM-DD HH:mm:ss UTC');
|
||||
}
|
||||
|
||||
return {
|
||||
utc : UtcFormatter
|
||||
}
|
||||
}
|
||||
RosaABF.factory("DateTimeFormatter", DateTimeFormatter);
|
||||
|
||||
RosaABF.factory("DateTimeFormatter", DateTimeFormatter);
|
||||
var LocalesHelper = function($locale) {
|
||||
var locales = {
|
||||
'ru' : 'ru-ru',
|
||||
'en' : 'en-us'
|
||||
}
|
||||
return {
|
||||
setLocale: function(locale) {
|
||||
$locale.id = locales[locale];
|
||||
}
|
||||
}
|
||||
}
|
||||
RosaABF.factory("LocalesHelper", ['$locale', LocalesHelper]);
|
|
@ -8,7 +8,7 @@ RosaABF.controller('ProjectRefsController', ['$scope', '$http', 'ApiProject', fu
|
|||
$scope.current_ref = null;
|
||||
$scope.project_resource = null;
|
||||
|
||||
$scope.init = function(project_id, ref) {
|
||||
$scope.init = function(project_id, ref, locale) {
|
||||
$scope.project_id = project_id;
|
||||
$scope.current_ref = ref;
|
||||
|
||||
|
@ -45,6 +45,8 @@ RosaABF.controller('ProjectRefsController', ['$scope', '$http', 'ApiProject', fu
|
|||
|
||||
}
|
||||
|
||||
$scope
|
||||
|
||||
$scope.updateBranchesCount = function() {
|
||||
$scope.singleton.project.branches_count = $scope.branches.length;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
RosaABF.controller('RosaABFController', ['$scope', 'LocalesHelper', function($scope, LocalesHelper) {
|
||||
|
||||
$scope.init = function(locale) {
|
||||
LocalesHelper.setLocale(locale);
|
||||
}
|
||||
|
||||
}]);
|
|
@ -0,0 +1,24 @@
|
|||
var _locales = {
|
||||
'ru-ru': {
|
||||
'total_branches': [
|
||||
'Всего %1 ветка',
|
||||
'Всего %1 ветки',
|
||||
'Всего %1 веток'
|
||||
],
|
||||
'total_tags': [
|
||||
'Всего %1 тег',
|
||||
'Всего %1 тега',
|
||||
'Всего %1 тегов'
|
||||
]
|
||||
},
|
||||
'en-us': {
|
||||
'total_branches': [
|
||||
'Total %1 branch',
|
||||
'Total %1 branches'
|
||||
],
|
||||
'total_tags': [
|
||||
'Total %1 tag',
|
||||
'Total %1 tags'
|
||||
]
|
||||
}
|
||||
};
|
|
@ -19,6 +19,7 @@
|
|||
// require angular-resource
|
||||
//= require unstable/angular-resource
|
||||
//= require ng-rails-csrf
|
||||
//= require angular-i18n
|
||||
//= require_tree ./angularjs
|
||||
//= require moment
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
- if user_signed_in?
|
||||
= auto_discovery_link_tag :atom, atom_activity_feeds_path(:format => 'atom', :token => current_user.authentication_token), :title => t("layout.atom_link_tag_title", :nickname => current_user.uname, :app_name => APP_CONFIG['project_name'])
|
||||
|
||||
%body{'ng-app' => 'RosaABF'}
|
||||
%body{'ng-app' => 'RosaABF', 'ng-controller' => 'RosaABFController', 'ng-init' => "init('#{I18n.locale}')"}
|
||||
.wrap{:class => content_for?(:sidebar) ? 'columns' : ''}
|
||||
%header
|
||||
.left
|
||||
|
|
|
@ -8,13 +8,7 @@
|
|||
|
||||
%h3= t('layout.projects.branches')
|
||||
%p{'ng-show' => '!branches.length'}= t('layout.projects.no_branches')
|
||||
%p{'ng-show' => 'branches.length == 1'}
|
||||
= t('layout.projects.total_branches', :count => '{{branches.length}}', :branches => t('layout.projects.pluralize.branches.branch'))
|
||||
%p{'ng-show' => 'branches.length > 1 && branches.length < 5'}
|
||||
= t('layout.projects.total_branches', :count => '{{branches.length}}', :branches => t('layout.projects.pluralize.branches.branches2'))
|
||||
%p{'ng-show' => 'branches.length > 4'}
|
||||
= t('layout.projects.total_branches', :count => '{{branches.length}}', :branches => t('layout.projects.pluralize.branches.branches'))
|
||||
|
||||
%p{'ng-show' => 'branches.length > 0'} {{'total_branches' | i18n:'plural':branches.length}}
|
||||
.both
|
||||
%br
|
||||
|
||||
|
|
|
@ -7,12 +7,7 @@
|
|||
|
||||
%h3= t('layout.projects.tags')
|
||||
%p{'ng-show' => '!tags.length'}= t('layout.projects.no_tags')
|
||||
%p{'ng-show' => 'tags.length == 1'}
|
||||
= t('layout.projects.total_tags', :count => '{{tags.length}}', :tags => t('layout.projects.pluralize.tags.tag'))
|
||||
%p{'ng-show' => 'tags.length > 1 && tags.length < 5'}
|
||||
= t('layout.projects.total_tags', :count => '{{tags.length}}', :tags => t('layout.projects.pluralize.tags.tags2'))
|
||||
%p{'ng-show' => 'tags.length > 4'}
|
||||
= t('layout.projects.total_tags', :count => '{{tags.length}}', :tags => t('layout.projects.pluralize.tags.tags'))
|
||||
%p{'ng-show' => 'tags.length > 0'} {{'total_tags' | i18n:'plural':tags.length}}
|
||||
.both
|
||||
%br
|
||||
|
||||
|
|
|
@ -2,27 +2,14 @@ en:
|
|||
layout:
|
||||
projects:
|
||||
branches: Branches
|
||||
|
||||
pluralize:
|
||||
branches:
|
||||
branch: branch
|
||||
branches: branches
|
||||
branches2: branches
|
||||
tags:
|
||||
tag: tag
|
||||
tags: tags
|
||||
tags2: tags
|
||||
|
||||
delete_branch: Delete branch
|
||||
restore_branch: Restore branch
|
||||
total_branches: Total %{count} %{branches}
|
||||
no_branches: No branches
|
||||
base_branch: Base branch
|
||||
compare: Compare
|
||||
browse_code: Browse code
|
||||
source_code: Source code (%{type})
|
||||
tags: Tags
|
||||
total_tags: Total %{count} %{tags}
|
||||
no_tags: No tags
|
||||
add: Add
|
||||
public_projects_list: Public projects list
|
||||
|
|
|
@ -2,27 +2,14 @@ ru:
|
|||
layout:
|
||||
projects:
|
||||
branches: Ветки
|
||||
|
||||
pluralize:
|
||||
branches:
|
||||
branch: ветка
|
||||
branches: веток
|
||||
branches2: ветки
|
||||
tags:
|
||||
tag: тег
|
||||
tags: тегов
|
||||
tags2: тега
|
||||
|
||||
delete_branch: Удалить ветку
|
||||
restore_branch: Востановить ветку
|
||||
total_branches: Всего %{count} %{branches}
|
||||
no_branches: Нет веток
|
||||
base_branch: Текущая ветка
|
||||
compare: Сравнить
|
||||
browse_code: Просмотреть код
|
||||
source_code: Исходный код (%{type})
|
||||
tags: Теги
|
||||
total_tags: Всего %{count} %{tags}
|
||||
no_tags: Нет тегов
|
||||
add: Добавить
|
||||
public_projects_list: Список публичных проектов
|
||||
|
|
Loading…
Reference in New Issue