mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04: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() {
|
||||
Meteor.subscribe('setting');
|
||||
|
||||
this.colorMap = {};
|
||||
for (const color of Boards.simpleSchema()._schema['labels.$.color']
|
||||
.allowedValues) {
|
||||
this.colorMap[TAPi18n.__(`color-${color}`)] = color;
|
||||
}
|
||||
// // eslint-disable-next-line no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('lang:', TAPi18n.getLanguage());
|
||||
this.colorMap = Boards.colorMap();
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('colorMap:', this.colorMap);
|
||||
|
||||
if (Session.get('globalQuery')) {
|
||||
|
@ -296,13 +294,14 @@ BlazeComponent.extendComponent({
|
|||
if (m.groups.operator) {
|
||||
op = m.groups.operator.toLowerCase();
|
||||
} else {
|
||||
op = m.groups.abbrev;
|
||||
op = m.groups.abbrev.toLowerCase();
|
||||
}
|
||||
if (operatorMap.hasOwnProperty(op)) {
|
||||
let value = m.groups.value;
|
||||
if (operatorMap[op] === 'labels') {
|
||||
if (value in this.colorMap) {
|
||||
value = this.colorMap[value];
|
||||
// console.log('found color:', value);
|
||||
}
|
||||
} else if (
|
||||
['dueAt', 'createdAt', 'modifiedAt'].includes(operatorMap[op])
|
||||
|
@ -388,7 +387,7 @@ BlazeComponent.extendComponent({
|
|||
params.text = text;
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('params:', params);
|
||||
console.log('params:', params);
|
||||
|
||||
this.queryParams = params;
|
||||
|
||||
|
|
|
@ -4,24 +4,24 @@
|
|||
|
||||
Meteor.startup(() => {
|
||||
TAPi18n.conf.i18n_files_route = Meteor._relativeToSiteRootUrl('/tap-i18n');
|
||||
Tracker.autorun(() => {
|
||||
const currentUser = Meteor.user();
|
||||
let language;
|
||||
if (currentUser) {
|
||||
language = currentUser.profile && currentUser.profile.language;
|
||||
}
|
||||
const currentUser = Meteor.user();
|
||||
let language;
|
||||
if (currentUser) {
|
||||
language = currentUser.profile && currentUser.profile.language;
|
||||
}
|
||||
|
||||
if (!language) {
|
||||
if (navigator.languages) {
|
||||
language = navigator.languages[0];
|
||||
} else {
|
||||
language = navigator.language || navigator.userLanguage;
|
||||
}
|
||||
if (!language) {
|
||||
if (navigator.languages) {
|
||||
language = navigator.languages[0];
|
||||
} else {
|
||||
language = navigator.language || navigator.userLanguage;
|
||||
}
|
||||
}
|
||||
|
||||
if (language) {
|
||||
TAPi18n.setLanguage(language);
|
||||
T9n.setLanguage(language);
|
||||
}
|
||||
});
|
||||
if (language) {
|
||||
TAPi18n.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) {
|
||||
Boards.allow({
|
||||
insert: Meteor.userId,
|
||||
|
|
|
@ -200,11 +200,7 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
|||
comments: [],
|
||||
};
|
||||
|
||||
this.colorMap = {};
|
||||
for (const color of Boards.simpleSchema()._schema['labels.$.color']
|
||||
.allowedValues) {
|
||||
this.colorMap[TAPi18n.__(`color-${color}`)] = color;
|
||||
}
|
||||
this.colorMap = Boards.colorMap();
|
||||
}
|
||||
|
||||
hasErrors() {
|
||||
|
@ -234,7 +230,11 @@ Meteor.publish('globalSearch', function(sessionId, queryParams) {
|
|||
});
|
||||
});
|
||||
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 => {
|
||||
messages.push({ tag: 'user-username-not-found', value: user });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue