Skip to content

Commit

Permalink
Use getLocale and getLanguage from nc-l10n
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed May 10, 2022
1 parent 290697b commit d5f9852
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 9 deletions.
14 changes: 11 additions & 3 deletions core/src/OC/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Handlebars from 'handlebars'
import identity from 'lodash/fp/identity'
import escapeHTML from 'escape-html'
import { generateFilePath } from '@nextcloud/router'
import { getLanguage as _getLanguage, getLocale as _getLocale } from '@nextcloud/l10n'

import OC from './index'
import {
Expand Down Expand Up @@ -348,16 +349,23 @@ export default L10n
/**
* Returns the user's locale
*
* @deprecated use @nextcloud/l10n
* @return {string} locale string
*/
export const getLocale = () => $('html').data('locale') ?? 'en'

export const getLocale = function() {
console.warn('Calling OC.getLocale() is deprecated, use @nextcloud/l10n instead.')
return _getLocale()
}
/**
* Returns the user's language
*
* @deprecated use @nextcloud/l10n
* @return {string} language string
*/
export const getLanguage = () => $('html').prop('lang')
export const getLanguage = function() {
console.warn('Calling OC.getLanguage() is deprecated, use @nextcloud/l10n instead.')
return _getLanguage()
}

Handlebars.registerHelper('t', function(app, text) {
return L10n.translate(app, text)
Expand Down
4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions dist/core-login.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@
*
*/

/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author rakekniven <mark.ziegler@rakekniven.de>
*
* @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/>.
*
*/

/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
* @copyright Copyright (c) 2019 Gary Kim <gary@garykim.dev>
Expand Down
2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions dist/core-main.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,30 @@
*
*/

/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author rakekniven <mark.ziegler@rakekniven.de>
*
* @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/>.
*
*/

/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
* @copyright Copyright (c) 2019 Gary Kim <gary@garykim.dev>
Expand Down
2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

0 comments on commit d5f9852

Please sign in to comment.