mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
Hopeful fix for i18n not working in onRendered()
* Remove the i18n initialization code from an `autorun()` block * Add some console statements to help with debugging production. * Add functions to `Boards` for label colors and color mapping
This commit is contained in:
parent
4fc2d7b935
commit
e4f50d4713
4 changed files with 42 additions and 31 deletions
|
@ -78,12 +78,10 @@ BlazeComponent.extendComponent({
|
||||||
onRendered() {
|
onRendered() {
|
||||||
Meteor.subscribe('setting');
|
Meteor.subscribe('setting');
|
||||||
|
|
||||||
this.colorMap = {};
|
// eslint-disable-next-line no-console
|
||||||
for (const color of Boards.simpleSchema()._schema['labels.$.color']
|
console.log('lang:', TAPi18n.getLanguage());
|
||||||
.allowedValues) {
|
this.colorMap = Boards.colorMap();
|
||||||
this.colorMap[TAPi18n.__(`color-${color}`)] = color;
|
// eslint-disable-next-line no-console
|
||||||
}
|
|
||||||
// // eslint-disable-next-line no-console
|
|
||||||
// console.log('colorMap:', this.colorMap);
|
// console.log('colorMap:', this.colorMap);
|
||||||
|
|
||||||
if (Session.get('globalQuery')) {
|
if (Session.get('globalQuery')) {
|
||||||
|
@ -296,13 +294,14 @@ BlazeComponent.extendComponent({
|
||||||
if (m.groups.operator) {
|
if (m.groups.operator) {
|
||||||
op = m.groups.operator.toLowerCase();
|
op = m.groups.operator.toLowerCase();
|
||||||
} else {
|
} else {
|
||||||
op = m.groups.abbrev;
|
op = m.groups.abbrev.toLowerCase();
|
||||||
}
|
}
|
||||||
if (operatorMap.hasOwnProperty(op)) {
|
if (operatorMap.hasOwnProperty(op)) {
|
||||||
let value = m.groups.value;
|
let value = m.groups.value;
|
||||||
if (operatorMap[op] === 'labels') {
|
if (operatorMap[op] === 'labels') {
|
||||||
if (value in this.colorMap) {
|
if (value in this.colorMap) {
|
||||||
value = this.colorMap[value];
|
value = this.colorMap[value];
|
||||||
|
// console.log('found color:', value);
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
['dueAt', 'createdAt', 'modifiedAt'].includes(operatorMap[op])
|
['dueAt', 'createdAt', 'modifiedAt'].includes(operatorMap[op])
|
||||||
|
@ -388,7 +387,7 @@ BlazeComponent.extendComponent({
|
||||||
params.text = text;
|
params.text = text;
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
// console.log('params:', params);
|
console.log('params:', params);
|
||||||
|
|
||||||
this.queryParams = params;
|
this.queryParams = params;
|
||||||
|
|
||||||
|
|
|
@ -4,24 +4,24 @@
|
||||||
|
|
||||||
Meteor.startup(() => {
|
Meteor.startup(() => {
|
||||||
TAPi18n.conf.i18n_files_route = Meteor._relativeToSiteRootUrl('/tap-i18n');
|
TAPi18n.conf.i18n_files_route = Meteor._relativeToSiteRootUrl('/tap-i18n');
|
||||||
Tracker.autorun(() => {
|
const currentUser = Meteor.user();
|
||||||
const currentUser = Meteor.user();
|
let language;
|
||||||
let language;
|
if (currentUser) {
|
||||||
if (currentUser) {
|
language = currentUser.profile && currentUser.profile.language;
|
||||||
language = currentUser.profile && currentUser.profile.language;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!language) {
|
if (!language) {
|
||||||
if (navigator.languages) {
|
if (navigator.languages) {
|
||||||
language = navigator.languages[0];
|
language = navigator.languages[0];
|
||||||
} else {
|
} else {
|
||||||
language = navigator.language || navigator.userLanguage;
|
language = navigator.language || navigator.userLanguage;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (language) {
|
if (language) {
|
||||||
TAPi18n.setLanguage(language);
|
TAPi18n.setLanguage(language);
|
||||||
T9n.setLanguage(language);
|
// eslint-disable-next-line no-console
|
||||||
}
|
console.log('language set!');
|
||||||
});
|
T9n.setLanguage(language);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1318,6 +1318,18 @@ Boards.userBoardIds = (userId, archived = false, selector = {}) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Boards.colorMap = () => {
|
||||||
|
const colors = {};
|
||||||
|
for (const color of Boards.labelColors()) {
|
||||||
|
colors[TAPi18n.__(`color-${color}`)] = color;
|
||||||
|
}
|
||||||
|
return colors;
|
||||||
|
};
|
||||||
|
|
||||||
|
Boards.labelColors = () => {
|
||||||
|
return _.clone(Boards.simpleSchema()._schema['labels.$.color'].allowedValues);
|
||||||
|
};
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
Boards.allow({
|
Boards.allow({
|
||||||
insert: Meteor.userId,
|
insert: Meteor.userId,
|
||||||
|
|
|
@ -200,11 +200,7 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
||||||
comments: [],
|
comments: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
this.colorMap = {};
|
this.colorMap = Boards.colorMap();
|
||||||
for (const color of Boards.simpleSchema()._schema['labels.$.color']
|
|
||||||
.allowedValues) {
|
|
||||||
this.colorMap[TAPi18n.__(`color-${color}`)] = color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hasErrors() {
|
hasErrors() {
|
||||||
|
@ -234,7 +230,11 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.notFound.labels.forEach(label => {
|
this.notFound.labels.forEach(label => {
|
||||||
messages.push({ tag: 'label-not-found', value: label, color: true });
|
messages.push({
|
||||||
|
tag: 'label-not-found',
|
||||||
|
value: label,
|
||||||
|
color: Boards.labelColors().includes(label),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
this.notFound.users.forEach(user => {
|
this.notFound.users.forEach(user => {
|
||||||
messages.push({ tag: 'user-username-not-found', value: user });
|
messages.push({ tag: 'user-username-not-found', value: user });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue