mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 05:09:43 +02:00
feat: Languages with country codes
This commit is contained in:
parent
79ad1836a8
commit
07e1903bb5
83 changed files with 211 additions and 99 deletions
|
@ -50,7 +50,7 @@ module.exports = {
|
|||
},
|
||||
language: {
|
||||
type: 'string',
|
||||
isNotEmptyString: true,
|
||||
isIn: User.LANGUAGES,
|
||||
allowNull: true,
|
||||
},
|
||||
subscribeToOwnCards: {
|
||||
|
|
|
@ -36,7 +36,7 @@ module.exports = {
|
|||
},
|
||||
language: {
|
||||
type: 'string',
|
||||
isNotEmptyString: true,
|
||||
isIn: User.LANGUAGES,
|
||||
allowNull: true,
|
||||
},
|
||||
subscribeToOwnCards: {
|
||||
|
|
|
@ -5,11 +5,39 @@
|
|||
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
|
||||
*/
|
||||
|
||||
const LANGUAGES = [
|
||||
'bg-BG',
|
||||
'cs-CZ',
|
||||
'da-DK',
|
||||
'de-DE',
|
||||
'en-US',
|
||||
'es-ES',
|
||||
'fa-IR',
|
||||
'fr-FR',
|
||||
'hu-HU',
|
||||
'id-ID',
|
||||
'it-IT',
|
||||
'ja-JP',
|
||||
'ko-KR',
|
||||
'nl-NL',
|
||||
'pl-PL',
|
||||
'pt-BR',
|
||||
'ro-RO',
|
||||
'ru-RU',
|
||||
'sk-SK',
|
||||
'sv-SE',
|
||||
'tr-TR',
|
||||
'uk-UA',
|
||||
'uz-UZ',
|
||||
'zh-CN',
|
||||
];
|
||||
|
||||
const OIDC = {
|
||||
id: '_oidc',
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
LANGUAGES,
|
||||
OIDC,
|
||||
|
||||
attributes: {
|
||||
|
@ -62,7 +90,7 @@ module.exports = {
|
|||
},
|
||||
language: {
|
||||
type: 'string',
|
||||
isNotEmptyString: true,
|
||||
isIn: LANGUAGES,
|
||||
allowNull: true,
|
||||
},
|
||||
subscribeToOwnCards: {
|
||||
|
|
|
@ -15,7 +15,7 @@ module.exports.up = async (knex) => {
|
|||
const attachments = await knex('attachment');
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (attachment of attachments) {
|
||||
for (const attachment of attachments) {
|
||||
if (attachment.is_image) {
|
||||
const image = sharp(
|
||||
path.join(config.custom.attachmentsPath, attachment.dirname, attachment.filename),
|
||||
|
@ -54,7 +54,7 @@ module.exports.down = async (knex) => {
|
|||
const attachments = await knex('attachment');
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (attachment of attachments) {
|
||||
for (const attachment of attachments) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await knex('attachment')
|
||||
.update({
|
||||
|
|
|
@ -93,7 +93,7 @@ module.exports.up = async (knex) => {
|
|||
const attachments = await knex('attachment').whereNotNull('image');
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (attachment of attachments) {
|
||||
for (const attachment of attachments) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const image = await processAttachmentImage(attachment, config.custom.attachmentsPath);
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ module.exports.up = async (knex) => {
|
|||
const users = await knex('user_account').whereNotNull('avatar');
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (user of users) {
|
||||
for (const user of users) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await processUserAvatar(user, config.custom.userAvatarsPath);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ module.exports.up = async (knex) => {
|
|||
const projects = await knex('project').whereNotNull('background_image');
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (project of projects) {
|
||||
for (const project of projects) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await processProjectBackgroundImage(project, config.custom.projectBackgroundImagesPath);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ module.exports.up = async (knex) => {
|
|||
const attachments = await knex('attachment').whereNotNull('image');
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (attachment of attachments) {
|
||||
for (const attachment of attachments) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await processAttachmentImage(attachment, config.custom.attachmentsPath);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
const _ = require('lodash');
|
||||
|
||||
const LANGUAGES = [
|
||||
'bg-BG',
|
||||
'cs-CZ',
|
||||
'da-DK',
|
||||
'de-DE',
|
||||
'en-US',
|
||||
'es-ES',
|
||||
'fa-IR',
|
||||
'fr-FR',
|
||||
'hu-HU',
|
||||
'id-ID',
|
||||
'it-IT',
|
||||
'ja-JP',
|
||||
'ko-KR',
|
||||
'nl-NL',
|
||||
'pl-PL',
|
||||
'pt-BR',
|
||||
'ro-RO',
|
||||
'ru-RU',
|
||||
'sk-SK',
|
||||
'sv-SE',
|
||||
'tr-TR',
|
||||
'uz-UZ',
|
||||
'zh-CN',
|
||||
];
|
||||
|
||||
const LANGUAGE_BY_PREV_LANGUAGE = LANGUAGES.reduce(
|
||||
(result, language) => ({
|
||||
...result,
|
||||
[language.split('-')[0]]: language,
|
||||
}),
|
||||
{},
|
||||
);
|
||||
LANGUAGE_BY_PREV_LANGUAGE.ua = 'uk-UA';
|
||||
|
||||
const PREV_LANGUAGE_BY_LANGUAGE = _.invert(LANGUAGE_BY_PREV_LANGUAGE);
|
||||
|
||||
module.exports.up = async (knex) => {
|
||||
const users = await knex('user_account').whereNotNull('language');
|
||||
const prevLanguages = [...new Set(users.map((user) => user.language))];
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const prevLanguage of prevLanguages) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await knex('user_account')
|
||||
.update({
|
||||
language: LANGUAGE_BY_PREV_LANGUAGE[prevLanguage],
|
||||
})
|
||||
.where('language', prevLanguage);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.down = async (knex) => {
|
||||
const users = await knex('user_account').whereNotNull('language');
|
||||
const languages = [...new Set(users.map((user) => user.language))];
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const language of languages) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await knex('user_account')
|
||||
.update({
|
||||
language: PREV_LANGUAGE_BY_LANGUAGE[language],
|
||||
})
|
||||
.where('language', language);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue