mirror of
https://github.com/documize/community.git
synced 2025-08-03 04:25:25 +02:00
Initial i18n experiment
This commit is contained in:
parent
32a9528e6d
commit
245c538990
12 changed files with 103 additions and 38 deletions
|
@ -44,6 +44,7 @@ export default Service.extend({
|
|||
updateAvailable: false,
|
||||
// empty theme uses default theme
|
||||
theme: '',
|
||||
locale: 'en-US',
|
||||
|
||||
getBaseUrl(endpoint) {
|
||||
return [this.get('endpoint'), endpoint].join('/');
|
||||
|
|
33
gui/app/services/i18n.js
Normal file
33
gui/app/services/i18n.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2022 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// https://www.documize.com
|
||||
|
||||
import Service, { inject as service } from '@ember/service';
|
||||
import $ from 'jquery';
|
||||
|
||||
export default Service.extend({
|
||||
langs: { enUS: [] },
|
||||
locales: [],
|
||||
session: service(),
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
$.getJSON("/i18n/en-US.json", (data) => {
|
||||
this.langs.enUS = data;
|
||||
});
|
||||
},
|
||||
|
||||
localize(key) {
|
||||
console.log(this.session.locale);
|
||||
|
||||
switch(this.session.locale) {
|
||||
case "fr-FR":
|
||||
return "unsupported";
|
||||
default:
|
||||
return this.langs.enUS[key];
|
||||
}
|
||||
},
|
||||
});
|
|
@ -99,6 +99,11 @@ export default SimpleAuthSession.extend({
|
|||
return this.get('session.content.authenticated.token');
|
||||
}),
|
||||
|
||||
locale: computed('session.content.authenticated.user', function () {
|
||||
let locale = this.get('session.content.authenticated.user.locale');
|
||||
if (_.isUndefined(locale) || locale === "") return this.appMeta.locale;
|
||||
}),
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue