diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-05-13 18:42:49 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-05-13 18:42:49 +0200 |
commit | a5ec4a9af4582691038ec241dfcafaa5144e5f5a (patch) | |
tree | c11fd4d60e9307fa883cd32e188ac65f206c21a6 /core/src/OC | |
parent | 2246003a3e9de98abebf03410c71dd6c03ec8e95 (diff) | |
download | nextcloud-server-a5ec4a9af4582691038ec241dfcafaa5144e5f5a.tar.gz nextcloud-server-a5ec4a9af4582691038ec241dfcafaa5144e5f5a.zip |
Move l10n functions to the bundle
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/src/OC')
-rw-r--r-- | core/src/OC/index.js | 12 | ||||
-rw-r--r-- | core/src/OC/l10n.js | 24 |
2 files changed, 36 insertions, 0 deletions
diff --git a/core/src/OC/index.js b/core/src/OC/index.js index 9838e63b0f8..3a76361d476 100644 --- a/core/src/OC/index.js +++ b/core/src/OC/index.js @@ -62,6 +62,11 @@ import { import {isUserAdmin} from './admin' import L10N from './l10n' import { + getCanonicalLocale, + getLanguage, + getLocale, +} from './l10n' +import { filePath, generateUrl, getRootPath, @@ -142,6 +147,13 @@ export default { isSamePath, joinPaths, + /** + * L10n + */ + getCanonicalLocale, + getLocale, + getLanguage, + msg, Notification, PasswordConfirmation, diff --git a/core/src/OC/l10n.js b/core/src/OC/l10n.js index 73c239569a0..30089b3427a 100644 --- a/core/src/OC/l10n.js +++ b/core/src/OC/l10n.js @@ -329,6 +329,30 @@ const L10n = { export default L10n; +/** + * Returns the user's locale as a BCP 47 compliant language tag + * + * @return {String} locale string + */ +export const getCanonicalLocale = () => { + const locale = getLocale() + return typeof locale === 'string' ? locale.replace(/_/g, '-') : locale +} + +/** + * Returns the user's locale + * + * @return {String} locale string + */ +export const getLocale = () => $('html').data('locale') + +/** + * Returns the user's language + * + * @returns {String} language string + */ +export const getLanguage = () => $('html').prop('lang') + Handlebars.registerHelper('t', function(app, text) { return L10n.translate(app, text); }); |