1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-18 20:59:43 +02:00

Initial i18n experiment

This commit is contained in:
McMatts 2022-03-01 16:22:53 -05:00
parent 32a9528e6d
commit 245c538990
12 changed files with 103 additions and 38 deletions

View file

@ -24,7 +24,11 @@ module.exports = {
"ember/no-get": "off",
"ember/no-jquery": "off",
"ember/no-mixins": "off",
"ember/no-actions-hash": "off"
"ember/no-actions-hash": "off",
"ember/require-computed-macros": "off",
"ember/use-ember-data-rfc-395-imports": "off",
"ember/avoid-leaking-state-in-ember-objects": "off",
"ember/require-return-from-computed": "off"
},
overrides: [
// node files

View file

@ -0,0 +1,17 @@
// 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 Helper from '@ember/component/helper';
import { inject as service } from '@ember/service';
export default Helper.extend({
i18n: service(),
compute([key, ...rest]) {
return this.i18n.localize(key, ...rest);
}
});

View file

@ -0,0 +1,19 @@
// 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
export function initialize(application) {
application.inject('route', 'i18n', 'service:i18n');
application.inject('controller', 'i18n', 'service:i18n');
application.inject('component', 'i18n', 'service:i18n');
application.inject('model', 'i18n', 'service:i18n');
}
export default {
name: 'i18n',
after: "application",
initialize: initialize
};

View file

@ -30,6 +30,7 @@ export default Model.extend({
theme: attr('string'),
created: attr(),
revised: attr(),
locale: attr('string', { defaultValue: "en-US" }),
fullname: computed('firstname', 'lastname', function () {
return `${this.get('firstname')} ${this.get('lastname')}`;

View file

@ -76,5 +76,4 @@ export default Controller.extend(AuthProvider, {
// }
}
}
});

View file

@ -23,7 +23,7 @@
<Layout::Grid::Sidebar>
<div class="sidebar-content">
<div class="section">
<div class="title">filter</div>
<div class="title">{{localize 'filter'}}</div>
<div class="list">
<div class="item {{if (eq selectedView "all") "selected"}}" {{action "onSelect" "all"}}>
<i class={{concat "dicon " constants.Icon.All}} />

View file

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

View file

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

View file

@ -0,0 +1,3 @@
{
"filter": "filterr"
}

View file

@ -4007,9 +4007,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001248:
version "1.0.30001251"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001251.tgz"
integrity sha512-HOe1r+9VkU4TFmnU70z+r7OLmtR+/chB1rdcJUeQlAinjEeb0cKL20tlAtOagNZhbrtLnCvV19B4FmF1rgzl6A==
version "1.0.30001312"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001312.tgz"
integrity sha512-Wiz1Psk2MEK0pX3rUzWaunLTZzqS2JYZFzNKqAiJGiuxIjRPLgV6+VDPOg6lQOUxmDwhTlh198JsTTi8Hzw6aQ==
capture-exit@^2.0.0:
version "2.0.0"
@ -4860,7 +4860,7 @@ debug@^3.0.1, debug@^3.1.0, debug@^3.1.1:
dependencies:
ms "^2.1.1"
debuglog@*, debuglog@^1.0.1:
debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/debuglog/-/debuglog-1.0.1.tgz"
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@ -7999,7 +7999,7 @@ import-lazy@^2.1.0:
resolved "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz"
integrity sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=
imurmurhash@*, imurmurhash@^0.1.4:
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz"
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
@ -9170,11 +9170,6 @@ lodash._baseflatten@^3.0.0:
lodash.isarguments "^3.0.0"
lodash.isarray "^3.0.0"
lodash._baseindexof@*:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=
lodash._baseuniq@~4.6.0:
version "4.6.0"
resolved "https://registry.npmjs.org/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz"
@ -9183,16 +9178,11 @@ lodash._baseuniq@~4.6.0:
lodash._createset "~4.0.0"
lodash._root "~3.0.0"
lodash._bindcallback@*, lodash._bindcallback@^3.0.0:
lodash._bindcallback@^3.0.0:
version "3.0.1"
resolved "https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz"
integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=
lodash._cacheindexof@*:
version "3.0.2"
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=
lodash._createassigner@^3.0.0:
version "3.1.1"
resolved "https://registry.npmjs.org/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz"
@ -9202,19 +9192,12 @@ lodash._createassigner@^3.0.0:
lodash._isiterateecall "^3.0.0"
lodash.restparam "^3.0.0"
lodash._createcache@*:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
dependencies:
lodash._getnative "^3.0.0"
lodash._createset@~4.0.0:
version "4.0.3"
resolved "https://registry.npmjs.org/lodash._createset/-/lodash._createset-4.0.3.tgz"
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=
lodash._getnative@*, lodash._getnative@^3.0.0:
lodash._getnative@^3.0.0:
version "3.9.1"
resolved "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz"
integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
@ -9417,7 +9400,7 @@ lodash.pick@^4.4.0:
resolved "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz"
integrity sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=
lodash.restparam@*, lodash.restparam@^3.0.0:
lodash.restparam@^3.0.0:
version "3.6.1"
resolved "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz"
integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
@ -10481,7 +10464,7 @@ npm-normalize-package-bin@^1.0.0, npm-normalize-package-bin@^1.0.1:
semver "^5.6.0"
validate-npm-package-name "^3.0.0"
npm-package-arg@^8.0.0, npm-package-arg@^8.0.1, npm-package-arg@^8.1.0, npm-package-arg@^8.1.1, npm-package-arg@^8.1.2, npm-package-arg@^8.1.4, npm-package-arg@^8.1.5:
npm-package-arg@^8.0.0, npm-package-arg@^8.0.1, npm-package-arg@^8.1.0, npm-package-arg@^8.1.1, npm-package-arg@^8.1.2, npm-package-arg@^8.1.5:
version "8.1.5"
resolved "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.5.tgz"
integrity sha512-LhgZrg0n0VgvzVdSm1oiZworPbTxYHUJCgtsJW8mGvlDpxTM1vSJc3m5QZeUkhAHIzbz3VCHd/R4osi1L1Tg/Q==
@ -11143,7 +11126,7 @@ pacote@11.3.3:
ssri "^8.0.1"
tar "^6.1.0"
pacote@^11.1.11, pacote@^11.2.6, pacote@^11.3.1, pacote@^11.3.4, pacote@^11.3.5:
pacote@^11.1.11, pacote@^11.2.6, pacote@^11.3.0, pacote@^11.3.1, pacote@^11.3.5:
version "11.3.5"
resolved "https://registry.npmjs.org/pacote/-/pacote-11.3.5.tgz"
integrity sha512-fT375Yczn4zi+6Hkk2TBe1x1sP8FgFsEIZ2/iWaXY2r/NkhDJfxbcn5paz1+RTFCyNf+dPnaoBDJoAxXSU8Bkg==
@ -11916,7 +11899,7 @@ readable-stream@~1.1.10:
isarray "0.0.1"
string_decoder "~0.10.x"
readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0, readdir-scoped-modules@^1.1.0:
readdir-scoped-modules@^1.0.0, readdir-scoped-modules@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/readdir-scoped-modules/-/readdir-scoped-modules-1.1.0.tgz"
integrity sha512-asaikDeqAQg7JifRsZn1NJZXo9E+VwlyCfbkZhwyISinqk5zNS6266HS5kah6P0SaQKGF6SkNnZVHUzHFYxYDw==
@ -14082,7 +14065,7 @@ v8-compile-cache@^2.2.0:
resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz"
integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==
validate-npm-package-license@*, validate-npm-package-license@^3.0.1, validate-npm-package-license@^3.0.4:
validate-npm-package-license@^3.0.1, validate-npm-package-license@^3.0.4:
version "3.0.4"
resolved "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz"
integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==