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 5, 2022
1 parent 290697b commit b35fc69
Showing 1 changed file with 11 additions and 3 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

0 comments on commit b35fc69

Please sign in to comment.