angular-i18n 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/angular-i18n.rb +8 -0
- data/lib/angular-i18n/version.rb +5 -0
- data/vendor/assets/javascripts/angular-i18n.js +40 -0
- metadata +50 -0
data/lib/angular-i18n.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
angular.module('tanzFilters', []);
|
4
|
+
angular.module('tanzFilters', []).filter('i18n', function($locale) {
|
5
|
+
return function(str) {
|
6
|
+
var offset = 1;
|
7
|
+
if (arguments[1] && arguments[1] === 'plural') {
|
8
|
+
var n = arguments[2],
|
9
|
+
plural;
|
10
|
+
|
11
|
+
switch ($locale.id) {
|
12
|
+
case 'en-us':
|
13
|
+
case 'de-de':
|
14
|
+
case 'es-es':
|
15
|
+
plural = 0 + (n != 1);
|
16
|
+
break;
|
17
|
+
case 'ru-ru':
|
18
|
+
plural = (n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
19
|
+
break;
|
20
|
+
case 'ar':
|
21
|
+
plural = n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
|
22
|
+
default:
|
23
|
+
plural = 0 + (n != 1);
|
24
|
+
}
|
25
|
+
|
26
|
+
if (_locales[$locale.id][str]) {
|
27
|
+
str = _locales[$locale.id][str][plural] || str;
|
28
|
+
}
|
29
|
+
offset = 2;
|
30
|
+
} else {
|
31
|
+
str = _locales[$locale.id][str] || str;
|
32
|
+
}
|
33
|
+
|
34
|
+
for (var i = offset; i < arguments.length; i++) {
|
35
|
+
str = str.split('%' + (i - offset + 1)).join(arguments[i]);
|
36
|
+
}
|
37
|
+
|
38
|
+
return str;
|
39
|
+
}
|
40
|
+
});
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: angular-i18n
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Vokhmin Alexey V
|
9
|
+
- Shavrin Artem
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
14
|
+
dependencies: []
|
15
|
+
description: AngularJS localization filter
|
16
|
+
email:
|
17
|
+
- avokhmin@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/angular-i18n/version.rb
|
23
|
+
- lib/angular-i18n.rb
|
24
|
+
- vendor/assets/javascripts/angular-i18n.js
|
25
|
+
homepage: https://github.com/avokhmin/angular-i18n
|
26
|
+
licenses: []
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 1.8.25
|
46
|
+
signing_key:
|
47
|
+
specification_version: 3
|
48
|
+
summary: AngularJS rails gem which you can load into any rails project for use localization
|
49
|
+
filter
|
50
|
+
test_files: []
|