summaryrefslogtreecommitdiffstats
path: root/core/src/OC/l10n.js
blob: b04d4bf9fbad6b4c479363c76569cb796cd6ce3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
 * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
 * Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 *
 * @author Christoph Wurst <christoph@winzerhof-wurst.at>
 * @author Daniel Kesselberg <mail@danielkesselberg.de>
 * @author Joas Schilling <coding@schilljs.com>
 * @author John Molakvoæ <skjnldsv@protonmail.com>
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Roeland Jago Douma <roeland@famdouma.nl>
 * @author Vincent Petry <vincent@nextcloud.com>
 *
 * @license AGPL-3.0-or-later
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */

import Handlebars from 'handlebars'
import {
	loadTranslations,
	translate,
	translatePlural,
	register,
	unregister,
} from '@nextcloud/l10n'

/**
 * L10N namespace with localization functions.
 *
 * @namespace OC.L10n
 * @deprecated 26.0.0 use https://www.npmjs.com/package/@nextcloud/l10n
 */
const L10n = {

	/**
	 * Load an app's translation bundle if not loaded already.
	 *
	 * @deprecated 26.0.0 use `loadTranslations` from https://www.npmjs.com/package/@nextcloud/l10n
	 *
	 * @param {string} appName name of the app
	 * @param {Function} callback callback to be called when
	 * the translations are loaded
	 * @return {Promise} promise
	 */
	load: loadTranslations,

	/**
	 * Register an app's translation bundle.
	 *
	 * @deprecated 26.0.0 use `register` from https://www.npmjs.com/package/@nextcloud/l10
	 *
	 * @param {string} appName name of the app
	 * @param {Object<string, string>} bundle bundle
	 */
	register,

	/**
	 * @private
	 * @deprecated 26.0.0 use `unregister` from https://www.npmjs.com/package/@nextcloud/l10n
	 */
	_unregister: unregister,

	/**
	 * Translate a string
	 *
	 * @deprecated 26.0.0 use `translate` from https://www.npmjs.com/package/@nextcloud/l10n
	 *
	 * @param {string} app the id of the app for which to translate the string
	 * @param {string} text the string to translate
	 * @param {object} [vars] map of placeholder key to value
	 * @param {number} [count] number to replace %n with
	 * @param {Array} [options] options array
	 * @param {boolean} [options.escape=true] enable/disable auto escape of placeholders (by default enabled)
	 * @param {boolean} [options.sanitize=true] enable/disable sanitization (by default enabled)
	 * @return {string}
	 */
	translate,

	/**
	 * Translate a plural string
	 *
	 * @deprecated 26.0.0 use `translatePlural` from https://www.npmjs.com/package/@nextcloud/l10n
	 *
	 * @param {string} app the id of the app for which to translate the string
	 * @param {string} textSingular the string to translate for exactly one object
	 * @param {string} textPlural the string to translate for n objects
	 * @param {number} count number to determine whether to use singular or plural
	 * @param {object} [vars] map of placeholder key to value
	 * @param {Array} [options] options array
	 * @param {boolean} [options.escape=true] enable/disable auto escape of placeholders (by default enabled)
	 * @return {string} Translated string
	 */
	translatePlural,
}

export default L10n

Handlebars.registerHelper('t', function(app, text) {
	return translate(app, text)
})