##// 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 1 module.exports = function(grunt) {
2 2 grunt.initConfig({
3 3
4 4 dirs: {
5 5 css: "rhodecode/public/css",
6 6 js: {
7 7 "src": "rhodecode/public/js/src",
8 8 "dest": "rhodecode/public/js"
9 9 }
10 10 },
11 11
12 12 concat: {
13 13 dist: {
14 14 src: [
15 15 // Base libraries
16 16 '<%= dirs.js.src %>/jquery-1.11.1.min.js',
17 17 '<%= dirs.js.src %>/logging.js',
18 18 '<%= dirs.js.src %>/bootstrap.js',
19 19 '<%= dirs.js.src %>/mousetrap.js',
20 20 '<%= dirs.js.src %>/moment.js',
21 21 '<%= dirs.js.src %>/appenlight-client-0.4.1.min.js',
22 '<%= dirs.js.src %>/i18n_utils.js',
22 23
23 24 // Plugins
24 25 '<%= dirs.js.src %>/plugins/jquery.pjax.js',
25 26 '<%= dirs.js.src %>/plugins/jquery.dataTables.js',
26 27 '<%= dirs.js.src %>/plugins/flavoured_checkbox.js',
27 28 '<%= dirs.js.src %>/plugins/jquery.auto-grow-input.js',
28 29 '<%= dirs.js.src %>/plugins/jquery.autocomplete.js',
29 30 '<%= dirs.js.src %>/plugins/jquery.debounce.js',
30 31 '<%= dirs.js.src %>/plugins/jquery.mark.js',
31 32 '<%= dirs.js.src %>/plugins/jquery.timeago.js',
32 33 '<%= dirs.js.src %>/plugins/jquery.timeago-extension.js',
33 34
34 35 // Select2
35 36 '<%= dirs.js.src %>/select2/select2.js',
36 37
37 38 // Code-mirror
38 39 '<%= dirs.js.src %>/codemirror/codemirror.js',
39 40 '<%= dirs.js.src %>/codemirror/codemirror_loadmode.js',
40 41 '<%= dirs.js.src %>/codemirror/codemirror_hint.js',
41 42 '<%= dirs.js.src %>/codemirror/codemirror_overlay.js',
42 43 '<%= dirs.js.src %>/codemirror/codemirror_placeholder.js',
43 44 // TODO: mikhail: this is an exception. Since the code mirror modes
44 45 // are loaded "on the fly", we need to keep them in a public folder
45 46 '<%= dirs.js.dest %>/mode/meta.js',
46 47 '<%= dirs.js.dest %>/mode/meta_ext.js',
47 48 '<%= dirs.js.dest %>/rhodecode/i18n/select2/translations.js',
48 49
49 50 // Rhodecode utilities
50 51 '<%= dirs.js.src %>/rhodecode/utils/array.js',
51 52 '<%= dirs.js.src %>/rhodecode/utils/string.js',
52 53 '<%= dirs.js.src %>/rhodecode/utils/pyroutes.js',
53 54 '<%= dirs.js.src %>/rhodecode/utils/ajax.js',
54 55 '<%= dirs.js.src %>/rhodecode/utils/autocomplete.js',
55 56 '<%= dirs.js.src %>/rhodecode/utils/colorgenerator.js',
56 57 '<%= dirs.js.src %>/rhodecode/utils/ie.js',
57 58 '<%= dirs.js.src %>/rhodecode/utils/os.js',
58 59
59 60 // Rhodecode widgets
60 61 '<%= dirs.js.src %>/rhodecode/widgets/multiselect.js',
61 62
62 63 // Rhodecode components
63 64 '<%= dirs.js.src %>/rhodecode/init.js',
64 65 '<%= dirs.js.src %>/rhodecode/codemirror.js',
65 66 '<%= dirs.js.src %>/rhodecode/comments.js',
66 67 '<%= dirs.js.src %>/rhodecode/constants.js',
67 68 '<%= dirs.js.src %>/rhodecode/files.js',
68 69 '<%= dirs.js.src %>/rhodecode/followers.js',
69 70 '<%= dirs.js.src %>/rhodecode/menus.js',
70 71 '<%= dirs.js.src %>/rhodecode/notifications.js',
71 72 '<%= dirs.js.src %>/rhodecode/permissions.js',
72 73 '<%= dirs.js.src %>/rhodecode/pjax.js',
73 74 '<%= dirs.js.src %>/rhodecode/pullrequests.js',
74 75 '<%= dirs.js.src %>/rhodecode/settings.js',
75 76 '<%= dirs.js.src %>/rhodecode/select2_widgets.js',
76 77 '<%= dirs.js.src %>/rhodecode/tooltips.js',
77 78 '<%= dirs.js.src %>/rhodecode/users.js',
78 79 '<%= dirs.js.src %>/rhodecode/appenlight.js',
79 80
80 81 // Rhodecode main module
81 82 '<%= dirs.js.src %>/rhodecode.js'
82 83 ],
83 84 dest: '<%= dirs.js.dest %>/scripts.js',
84 85 nonull: true
85 86 }
86 87 },
87 88
88 89 less: {
89 90 development: {
90 91 options: {
91 92 compress: false,
92 93 yuicompress: false,
93 94 optimization: 0
94 95 },
95 96 files: {
96 97 "<%= dirs.css %>/style.css": "<%= dirs.css %>/main.less"
97 98 }
98 99 },
99 100 production: {
100 101 options: {
101 102 compress: true,
102 103 yuicompress: true,
103 104 optimization: 2
104 105 },
105 106 files: {
106 107 "<%= dirs.css %>/style.css": "<%= dirs.css %>/main.less"
107 108 }
108 109 }
109 110 },
110 111
111 112 watch: {
112 113 less: {
113 114 files: ["<%= dirs.css %>/*.less"],
114 115 tasks: ["less:production"]
115 116 },
116 117 js: {
117 118 files: ["<%= dirs.js.src %>/**/*.js"],
118 119 tasks: ["concat:dist"]
119 120 }
120 121 },
121 122
122 123 jshint: {
123 124 rhodecode: {
124 125 src: '<%= dirs.js.src %>/rhodecode/**/*.js',
125 126 options: {
126 127 jshintrc: '.jshintrc'
127 128 }
128 129 }
129 130 }
130 131 });
131 132
132 133 grunt.loadNpmTasks('grunt-contrib-less');
133 134 grunt.loadNpmTasks('grunt-contrib-concat');
134 135 grunt.loadNpmTasks('grunt-contrib-watch');
135 136 grunt.loadNpmTasks('grunt-contrib-jshint');
136 137
137 138 grunt.registerTask('default', ['less:production', 'concat:dist']);
138 139 };
General Comments 0
You need to be logged in to leave comments. Login now