Move l10n functions to the bundle

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
pull/15518/head
Christoph Wurst 7 years ago
parent 2246003a3e
commit a5ec4a9af4
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
  1. 10
      core/js/dist/login.js
  2. 2
      core/js/dist/login.js.map
  3. 10
      core/js/dist/main.js
  4. 2
      core/js/dist/main.js.map
  5. 28
      core/js/js.js
  6. 14
      core/js/tests/specs/coreSpec.js
  7. 12
      core/src/OC/index.js
  8. 24
      core/src/OC/l10n.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -220,34 +220,6 @@ Object.assign(window.OC, {
}
},
/**
* Returns the user's locale as a BCP 47 compliant language tag
*
* @return {String} locale string
*/
getCanonicalLocale: function() {
var locale = this.getLocale();
return typeof locale === 'string' ? locale.replace(/_/g, '-') : locale;
},
/**
* Returns the user's locale
*
* @return {String} locale string
*/
getLocale: function() {
return $('html').data('locale');
},
/**
* Returns the user's language
*
* @returns {String} language string
*/
getLanguage: function () {
return $('html').prop('lang');
},
/**
* Warn users that the connection to the server was lost temporarily
*

@ -274,25 +274,25 @@ describe('Core base tests', function() {
});
});
describe('getCanonicalLocale', function() {
var localeStub;
var oldLocale;
beforeEach(function() {
localeStub = sinon.stub(OC, 'getLocale');
oldLocale = $('html').data('locale')
});
afterEach(function() {
localeStub.restore();
$('html').data('locale', oldLocale)
});
it("Returns primary locales as is", function() {
localeStub.returns('de');
$('html').data('locale', 'de')
expect(OC.getCanonicalLocale()).toEqual('de');
localeStub.returns('zu');
$('html').data('locale', 'zu')
expect(OC.getCanonicalLocale()).toEqual('zu');
});
it("Returns extended locales with hyphens", function() {
localeStub.returns('az_Cyrl_AZ');
$('html').data('locale', 'az_Cyrl_AZ')
expect(OC.getCanonicalLocale()).toEqual('az-Cyrl-AZ');
localeStub.returns('de_DE');
$('html').data('locale', 'de_DE')
expect(OC.getCanonicalLocale()).toEqual('de-DE');
});
});

@ -61,6 +61,11 @@ import {
} from './menu'
import {isUserAdmin} from './admin'
import L10N from './l10n'
import {
getCanonicalLocale,
getLanguage,
getLocale,
} from './l10n'
import {
filePath,
generateUrl,
@ -142,6 +147,13 @@ export default {
isSamePath,
joinPaths,
/**
* L10n
*/
getCanonicalLocale,
getLocale,
getLanguage,
msg,
Notification,
PasswordConfirmation,

@ -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);
});

Loading…
Cancel
Save