##// END OF EJS Templates
i18n: added JS utils for translation.
marcink -
r324:98b8711e stable
parent child Browse files
Show More
@@ -0,0 +1,36 b''
1 // # Copyright (C) 2016-2016 RhodeCode GmbH
2 // #
3 // # This program is free software: you can redistribute it and/or modify
4 // # it under the terms of the GNU Affero General Public License, version 3
5 // # (only), as published by the Free Software Foundation.
6 // #
7 // # This program is distributed in the hope that it will be useful,
8 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // # GNU General Public License for more details.
11 // #
12 // # You should have received a copy of the GNU Affero General Public License
13 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 // #
15 // # This program is dual-licensed. If you wish to learn more about the
16 // # RhodeCode Enterprise Edition, including its added features, Support services,
17 // # and proprietary license terms, please see https://rhodecode.com/licenses/
18
19 i18nLog = Logger.get('i18n');
20
21 var _gettext = function (s) {
22 if (_TM.hasOwnProperty(s)) {
23 return _TM[s];
24 }
25 i18nLog.error(
26 'String `' + s + '` was requested but cannot be ' +
27 'found in translation table');
28 return s
29 };
30
31 var _ngettext = function (singular, plural, n) {
32 if (n === 1) {
33 return _gettext(singular)
34 }
35 return _gettext(plural)
36 };
@@ -1,138 +1,139 b''
1 module.exports = function(grunt) {
1 module.exports = function(grunt) {
2 grunt.initConfig({
2 grunt.initConfig({
3
3
4 dirs: {
4 dirs: {
5 css: "rhodecode/public/css",
5 css: "rhodecode/public/css",
6 js: {
6 js: {
7 "src": "rhodecode/public/js/src",
7 "src": "rhodecode/public/js/src",
8 "dest": "rhodecode/public/js"
8 "dest": "rhodecode/public/js"
9 }
9 }
10 },
10 },
11
11
12 concat: {
12 concat: {
13 dist: {
13 dist: {
14 src: [
14 src: [
15 // Base libraries
15 // Base libraries
16 '<%= dirs.js.src %>/jquery-1.11.1.min.js',
16 '<%= dirs.js.src %>/jquery-1.11.1.min.js',
17 '<%= dirs.js.src %>/logging.js',
17 '<%= dirs.js.src %>/logging.js',
18 '<%= dirs.js.src %>/bootstrap.js',
18 '<%= dirs.js.src %>/bootstrap.js',
19 '<%= dirs.js.src %>/mousetrap.js',
19 '<%= dirs.js.src %>/mousetrap.js',
20 '<%= dirs.js.src %>/moment.js',
20 '<%= dirs.js.src %>/moment.js',
21 '<%= dirs.js.src %>/appenlight-client-0.4.1.min.js',
21 '<%= dirs.js.src %>/appenlight-client-0.4.1.min.js',
22 '<%= dirs.js.src %>/i18n_utils.js',
22
23
23 // Plugins
24 // Plugins
24 '<%= dirs.js.src %>/plugins/jquery.pjax.js',
25 '<%= dirs.js.src %>/plugins/jquery.pjax.js',
25 '<%= dirs.js.src %>/plugins/jquery.dataTables.js',
26 '<%= dirs.js.src %>/plugins/jquery.dataTables.js',
26 '<%= dirs.js.src %>/plugins/flavoured_checkbox.js',
27 '<%= dirs.js.src %>/plugins/flavoured_checkbox.js',
27 '<%= dirs.js.src %>/plugins/jquery.auto-grow-input.js',
28 '<%= dirs.js.src %>/plugins/jquery.auto-grow-input.js',
28 '<%= dirs.js.src %>/plugins/jquery.autocomplete.js',
29 '<%= dirs.js.src %>/plugins/jquery.autocomplete.js',
29 '<%= dirs.js.src %>/plugins/jquery.debounce.js',
30 '<%= dirs.js.src %>/plugins/jquery.debounce.js',
30 '<%= dirs.js.src %>/plugins/jquery.mark.js',
31 '<%= dirs.js.src %>/plugins/jquery.mark.js',
31 '<%= dirs.js.src %>/plugins/jquery.timeago.js',
32 '<%= dirs.js.src %>/plugins/jquery.timeago.js',
32 '<%= dirs.js.src %>/plugins/jquery.timeago-extension.js',
33 '<%= dirs.js.src %>/plugins/jquery.timeago-extension.js',
33
34
34 // Select2
35 // Select2
35 '<%= dirs.js.src %>/select2/select2.js',
36 '<%= dirs.js.src %>/select2/select2.js',
36
37
37 // Code-mirror
38 // Code-mirror
38 '<%= dirs.js.src %>/codemirror/codemirror.js',
39 '<%= dirs.js.src %>/codemirror/codemirror.js',
39 '<%= dirs.js.src %>/codemirror/codemirror_loadmode.js',
40 '<%= dirs.js.src %>/codemirror/codemirror_loadmode.js',
40 '<%= dirs.js.src %>/codemirror/codemirror_hint.js',
41 '<%= dirs.js.src %>/codemirror/codemirror_hint.js',
41 '<%= dirs.js.src %>/codemirror/codemirror_overlay.js',
42 '<%= dirs.js.src %>/codemirror/codemirror_overlay.js',
42 '<%= dirs.js.src %>/codemirror/codemirror_placeholder.js',
43 '<%= dirs.js.src %>/codemirror/codemirror_placeholder.js',
43 // TODO: mikhail: this is an exception. Since the code mirror modes
44 // TODO: mikhail: this is an exception. Since the code mirror modes
44 // are loaded "on the fly", we need to keep them in a public folder
45 // are loaded "on the fly", we need to keep them in a public folder
45 '<%= dirs.js.dest %>/mode/meta.js',
46 '<%= dirs.js.dest %>/mode/meta.js',
46 '<%= dirs.js.dest %>/mode/meta_ext.js',
47 '<%= dirs.js.dest %>/mode/meta_ext.js',
47 '<%= dirs.js.dest %>/rhodecode/i18n/select2/translations.js',
48 '<%= dirs.js.dest %>/rhodecode/i18n/select2/translations.js',
48
49
49 // Rhodecode utilities
50 // Rhodecode utilities
50 '<%= dirs.js.src %>/rhodecode/utils/array.js',
51 '<%= dirs.js.src %>/rhodecode/utils/array.js',
51 '<%= dirs.js.src %>/rhodecode/utils/string.js',
52 '<%= dirs.js.src %>/rhodecode/utils/string.js',
52 '<%= dirs.js.src %>/rhodecode/utils/pyroutes.js',
53 '<%= dirs.js.src %>/rhodecode/utils/pyroutes.js',
53 '<%= dirs.js.src %>/rhodecode/utils/ajax.js',
54 '<%= dirs.js.src %>/rhodecode/utils/ajax.js',
54 '<%= dirs.js.src %>/rhodecode/utils/autocomplete.js',
55 '<%= dirs.js.src %>/rhodecode/utils/autocomplete.js',
55 '<%= dirs.js.src %>/rhodecode/utils/colorgenerator.js',
56 '<%= dirs.js.src %>/rhodecode/utils/colorgenerator.js',
56 '<%= dirs.js.src %>/rhodecode/utils/ie.js',
57 '<%= dirs.js.src %>/rhodecode/utils/ie.js',
57 '<%= dirs.js.src %>/rhodecode/utils/os.js',
58 '<%= dirs.js.src %>/rhodecode/utils/os.js',
58
59
59 // Rhodecode widgets
60 // Rhodecode widgets
60 '<%= dirs.js.src %>/rhodecode/widgets/multiselect.js',
61 '<%= dirs.js.src %>/rhodecode/widgets/multiselect.js',
61
62
62 // Rhodecode components
63 // Rhodecode components
63 '<%= dirs.js.src %>/rhodecode/init.js',
64 '<%= dirs.js.src %>/rhodecode/init.js',
64 '<%= dirs.js.src %>/rhodecode/codemirror.js',
65 '<%= dirs.js.src %>/rhodecode/codemirror.js',
65 '<%= dirs.js.src %>/rhodecode/comments.js',
66 '<%= dirs.js.src %>/rhodecode/comments.js',
66 '<%= dirs.js.src %>/rhodecode/constants.js',
67 '<%= dirs.js.src %>/rhodecode/constants.js',
67 '<%= dirs.js.src %>/rhodecode/files.js',
68 '<%= dirs.js.src %>/rhodecode/files.js',
68 '<%= dirs.js.src %>/rhodecode/followers.js',
69 '<%= dirs.js.src %>/rhodecode/followers.js',
69 '<%= dirs.js.src %>/rhodecode/menus.js',
70 '<%= dirs.js.src %>/rhodecode/menus.js',
70 '<%= dirs.js.src %>/rhodecode/notifications.js',
71 '<%= dirs.js.src %>/rhodecode/notifications.js',
71 '<%= dirs.js.src %>/rhodecode/permissions.js',
72 '<%= dirs.js.src %>/rhodecode/permissions.js',
72 '<%= dirs.js.src %>/rhodecode/pjax.js',
73 '<%= dirs.js.src %>/rhodecode/pjax.js',
73 '<%= dirs.js.src %>/rhodecode/pullrequests.js',
74 '<%= dirs.js.src %>/rhodecode/pullrequests.js',
74 '<%= dirs.js.src %>/rhodecode/settings.js',
75 '<%= dirs.js.src %>/rhodecode/settings.js',
75 '<%= dirs.js.src %>/rhodecode/select2_widgets.js',
76 '<%= dirs.js.src %>/rhodecode/select2_widgets.js',
76 '<%= dirs.js.src %>/rhodecode/tooltips.js',
77 '<%= dirs.js.src %>/rhodecode/tooltips.js',
77 '<%= dirs.js.src %>/rhodecode/users.js',
78 '<%= dirs.js.src %>/rhodecode/users.js',
78 '<%= dirs.js.src %>/rhodecode/appenlight.js',
79 '<%= dirs.js.src %>/rhodecode/appenlight.js',
79
80
80 // Rhodecode main module
81 // Rhodecode main module
81 '<%= dirs.js.src %>/rhodecode.js'
82 '<%= dirs.js.src %>/rhodecode.js'
82 ],
83 ],
83 dest: '<%= dirs.js.dest %>/scripts.js',
84 dest: '<%= dirs.js.dest %>/scripts.js',
84 nonull: true
85 nonull: true
85 }
86 }
86 },
87 },
87
88
88 less: {
89 less: {
89 development: {
90 development: {
90 options: {
91 options: {
91 compress: false,
92 compress: false,
92 yuicompress: false,
93 yuicompress: false,
93 optimization: 0
94 optimization: 0
94 },
95 },
95 files: {
96 files: {
96 "<%= dirs.css %>/style.css": "<%= dirs.css %>/main.less"
97 "<%= dirs.css %>/style.css": "<%= dirs.css %>/main.less"
97 }
98 }
98 },
99 },
99 production: {
100 production: {
100 options: {
101 options: {
101 compress: true,
102 compress: true,
102 yuicompress: true,
103 yuicompress: true,
103 optimization: 2
104 optimization: 2
104 },
105 },
105 files: {
106 files: {
106 "<%= dirs.css %>/style.css": "<%= dirs.css %>/main.less"
107 "<%= dirs.css %>/style.css": "<%= dirs.css %>/main.less"
107 }
108 }
108 }
109 }
109 },
110 },
110
111
111 watch: {
112 watch: {
112 less: {
113 less: {
113 files: ["<%= dirs.css %>/*.less"],
114 files: ["<%= dirs.css %>/*.less"],
114 tasks: ["less:production"]
115 tasks: ["less:production"]
115 },
116 },
116 js: {
117 js: {
117 files: ["<%= dirs.js.src %>/**/*.js"],
118 files: ["<%= dirs.js.src %>/**/*.js"],
118 tasks: ["concat:dist"]
119 tasks: ["concat:dist"]
119 }
120 }
120 },
121 },
121
122
122 jshint: {
123 jshint: {
123 rhodecode: {
124 rhodecode: {
124 src: '<%= dirs.js.src %>/rhodecode/**/*.js',
125 src: '<%= dirs.js.src %>/rhodecode/**/*.js',
125 options: {
126 options: {
126 jshintrc: '.jshintrc'
127 jshintrc: '.jshintrc'
127 }
128 }
128 }
129 }
129 }
130 }
130 });
131 });
131
132
132 grunt.loadNpmTasks('grunt-contrib-less');
133 grunt.loadNpmTasks('grunt-contrib-less');
133 grunt.loadNpmTasks('grunt-contrib-concat');
134 grunt.loadNpmTasks('grunt-contrib-concat');
134 grunt.loadNpmTasks('grunt-contrib-watch');
135 grunt.loadNpmTasks('grunt-contrib-watch');
135 grunt.loadNpmTasks('grunt-contrib-jshint');
136 grunt.loadNpmTasks('grunt-contrib-jshint');
136
137
137 grunt.registerTask('default', ['less:production', 'concat:dist']);
138 grunt.registerTask('default', ['less:production', 'concat:dist']);
138 };
139 };
General Comments 0
You need to be logged in to leave comments. Login now