Skip to content

Commit 27b55b4

Browse files
Move OC.L10n to the server bundle
Signed-off-by: Christoph Wurst <[email protected]>
1 parent 3695d02 commit 27b55b4

File tree

7 files changed

+49
-35
lines changed

7 files changed

+49
-35
lines changed

core/js/core.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
"jquery.ocdialog.js",
1010
"oc-dialogs.js",
1111
"js.js",
12+
<<<<<<< HEAD
1213
"l10n.js",
14+
=======
15+
"oc-backbone.js",
16+
"oc-backbone-webdav.js",
17+
>>>>>>> Move OC.L10n to the server bundle
1318
"share.js",
1419
"sharetemplates.js",
1520
"sharesocialmanager.js",

core/js/dist/main.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/js/dist/main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/js/merged-template-prepend.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"jquery.ocdialog.js",
33
"oc-dialogs.js",
44
"js.js",
5-
"l10n.js",
65
"octemplate.js",
76
"public/appconfig.js",
87
"public/comments.js",

core/src/OC/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Apps from './apps'
2525
import AppConfig from './appconfig'
2626
import ContactsMenu from './contactsmenu';
2727
import EventSource from './eventsource'
28+
import L10N from './l10n'
2829
import {davCall, davSync} from './backbone-webdav';
2930

3031
// Patch Backbone for DAV
@@ -38,6 +39,7 @@ export default {
3839
Apps,
3940
AppConfig,
4041
Backbone,
41-
EventSource,
4242
ContactsMenu,
43+
EventSource,
44+
L10N,
4345
};

core/js/l10n.js renamed to core/src/OC/l10n.js

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@
88
*
99
*/
1010

11+
import _ from 'underscore'
12+
import $ from 'jquery'
13+
import Handlebars from 'handlebars'
14+
15+
import OC from './index'
16+
1117
/**
1218
* L10N namespace with localization functions.
1319
*
14-
* @namespace
20+
* @namespace OC.L10n
1521
*/
16-
OC.L10N = {
22+
const L10n = {
1723
/**
1824
* String bundles with app name as key.
1925
* @type {Object.<String,String>}
@@ -321,28 +327,9 @@ OC.L10N = {
321327
}
322328
};
323329

324-
/**
325-
* translate a string
326-
* @param {string} app the id of the app for which to translate the string
327-
* @param {string} text the string to translate
328-
* @param [vars] map of placeholder key to value
329-
* @param {number} [count] number to replace %n with
330-
* @return {string}
331-
*/
332-
window.t = _.bind(OC.L10N.translate, OC.L10N);
333-
334-
/**
335-
* translate a string
336-
* @param {string} app the id of the app for which to translate the string
337-
* @param {string} text_singular the string to translate for exactly one object
338-
* @param {string} text_plural the string to translate for n objects
339-
* @param {number} count number to determine whether to use singular or plural
340-
* @param [vars] map of placeholder key to value
341-
* @return {string} Translated string
342-
*/
343-
window.n = _.bind(OC.L10N.translatePlural, OC.L10N);
330+
export default L10n;
344331

345332
Handlebars.registerHelper('t', function(app, text) {
346-
return OC.L10N.translate(app, text);
333+
return L10n.translate(app, text);
347334
});
348335

core/src/globals.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,24 @@ window['moment'] = moment
7272
window['OC'] = OC
7373
window['OCP'] = OCP
7474
window['OCA'] = OCA
75+
76+
/**
77+
* translate a string
78+
* @param {string} app the id of the app for which to translate the string
79+
* @param {string} text the string to translate
80+
* @param [vars] map of placeholder key to value
81+
* @param {number} [count] number to replace %n with
82+
* @return {string}
83+
*/
84+
window.t = _.bind(OC.L10N.translate, OC.L10N);
85+
86+
/**
87+
* translate a string
88+
* @param {string} app the id of the app for which to translate the string
89+
* @param {string} text_singular the string to translate for exactly one object
90+
* @param {string} text_plural the string to translate for n objects
91+
* @param {number} count number to determine whether to use singular or plural
92+
* @param [vars] map of placeholder key to value
93+
* @return {string} Translated string
94+
*/
95+
window.n = _.bind(OC.L10N.translatePlural, OC.L10N);

0 commit comments

Comments
 (0)