forked from FoundKeyGang/FoundKey
backend: localize strings for service integrations
Currently only the 'connected' and 'disconnected' strings are translated.
This commit is contained in:
parent
57f4312a27
commit
e507b1b888
6 changed files with 59 additions and 8 deletions
|
@ -1409,3 +1409,13 @@ _deck:
|
||||||
list: "List"
|
list: "List"
|
||||||
mentions: "Mentions"
|
mentions: "Mentions"
|
||||||
direct: "Direct notes"
|
direct: "Direct notes"
|
||||||
|
_services:
|
||||||
|
_discord:
|
||||||
|
connected: "Discord: @{username}#{discriminator} connected to FoundKey: @{mkUsername}!"
|
||||||
|
disconnected: "Discord linkage has been removed :v:"
|
||||||
|
_twitter:
|
||||||
|
connected: "Twitter: @{twitterUserName} connected to FoundKey: @{userName}!"
|
||||||
|
disconnected: "Twitter linkage has been removed :v:"
|
||||||
|
_github:
|
||||||
|
connected: "GitHub: @{login} connected to FoundKey: @{userName}!"
|
||||||
|
disconnected: "GitHub linkage has been removed :v:"
|
||||||
|
|
|
@ -1452,3 +1452,13 @@ _deck:
|
||||||
list: "リスト"
|
list: "リスト"
|
||||||
mentions: "あなた宛て"
|
mentions: "あなた宛て"
|
||||||
direct: "ダイレクト"
|
direct: "ダイレクト"
|
||||||
|
_services:
|
||||||
|
_discord:
|
||||||
|
connected: "Discord: @{username}#{discriminator} を、FoundKey: @{mkUsername} に接続しました!"
|
||||||
|
disconnected: "Discordの連携を解除しました :v:"
|
||||||
|
_twitter:
|
||||||
|
connected: "Twitter: @{twitterUserName} を、FoundKey: @{userName} に接続しました!"
|
||||||
|
disconnected: "Twitterの連携を解除しました :v:"
|
||||||
|
_github:
|
||||||
|
connected: "GitHub: @{login} を、FoundKey: @{userName} に接続しました!"
|
||||||
|
disconnected: "GitHubの連携を解除しました :v:"
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { fetchMeta } from '@/misc/fetch-meta.js';
|
||||||
import { Users, UserProfiles } from '@/models/index.js';
|
import { Users, UserProfiles } from '@/models/index.js';
|
||||||
import { ILocalUser } from '@/models/entities/user.js';
|
import { ILocalUser } from '@/models/entities/user.js';
|
||||||
import { redisClient } from '@/db/redis.js';
|
import { redisClient } from '@/db/redis.js';
|
||||||
|
import { I18n } from '@/misc/i18n.js';
|
||||||
import signin from '../common/signin.js';
|
import signin from '../common/signin.js';
|
||||||
|
|
||||||
function getUserToken(ctx: Koa.BaseContext): string | null {
|
function getUserToken(ctx: Koa.BaseContext): string | null {
|
||||||
|
@ -26,6 +27,8 @@ function compareOrigin(ctx: Koa.BaseContext): boolean {
|
||||||
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const locales = await import('../../../../../../locales/index.js').then(mod => mod.default);
|
||||||
|
|
||||||
// Init router
|
// Init router
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
|
@ -47,6 +50,8 @@ router.get('/disconnect/discord', async ctx => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||||
|
const locale = locales[profile.lang || 'en-US'];
|
||||||
|
const i18n = new I18n(locale);
|
||||||
|
|
||||||
delete profile.integrations.discord;
|
delete profile.integrations.discord;
|
||||||
|
|
||||||
|
@ -54,7 +59,7 @@ router.get('/disconnect/discord', async ctx => {
|
||||||
integrations: profile.integrations,
|
integrations: profile.integrations,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.body = 'Discordの連携を解除しました :v:';
|
ctx.body = i18n.t('_services._discord.disconnected');
|
||||||
|
|
||||||
// Publish i updated event
|
// Publish i updated event
|
||||||
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
||||||
|
@ -259,6 +264,8 @@ router.get('/dc/cb', async ctx => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||||
|
const locale = locales[profile.lang || 'en-US'];
|
||||||
|
const i18n = new I18n(locale);
|
||||||
|
|
||||||
await UserProfiles.update(user.id, {
|
await UserProfiles.update(user.id, {
|
||||||
integrations: {
|
integrations: {
|
||||||
|
@ -274,7 +281,11 @@ router.get('/dc/cb', async ctx => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.body = `Discord: @${username}#${discriminator} connected to FoundKey: @${user.username}!`;
|
ctx.body = i18n.t('_services._discord.connected', {
|
||||||
|
username,
|
||||||
|
discriminator,
|
||||||
|
mkUsername: user.username,
|
||||||
|
});
|
||||||
|
|
||||||
// Publish i updated event
|
// Publish i updated event
|
||||||
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { Users, UserProfiles } from '@/models/index.js';
|
||||||
import { ILocalUser } from '@/models/entities/user.js';
|
import { ILocalUser } from '@/models/entities/user.js';
|
||||||
import { redisClient } from '@/db/redis.js';
|
import { redisClient } from '@/db/redis.js';
|
||||||
import signin from '../common/signin.js';
|
import signin from '../common/signin.js';
|
||||||
|
import { I18n } from '@/misc/i18n.js';
|
||||||
|
|
||||||
function getUserToken(ctx: Koa.BaseContext): string | null {
|
function getUserToken(ctx: Koa.BaseContext): string | null {
|
||||||
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||||
|
@ -26,6 +27,8 @@ function compareOrigin(ctx: Koa.BaseContext): boolean {
|
||||||
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const locales = await import('../../../../../../locales/index.js').then(mod => mod.default);
|
||||||
|
|
||||||
// Init router
|
// Init router
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
|
@ -47,6 +50,8 @@ router.get('/disconnect/github', async ctx => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||||
|
const locale = locales[profile.lang || 'en-US'];
|
||||||
|
const i18n = new I18n(locale);
|
||||||
|
|
||||||
delete profile.integrations.github;
|
delete profile.integrations.github;
|
||||||
|
|
||||||
|
@ -54,7 +59,7 @@ router.get('/disconnect/github', async ctx => {
|
||||||
integrations: profile.integrations,
|
integrations: profile.integrations,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.body = 'GitHubの連携を解除しました :v:';
|
ctx.body = i18n.t('_services._github.disconnected');
|
||||||
|
|
||||||
// Publish i updated event
|
// Publish i updated event
|
||||||
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
||||||
|
@ -234,6 +239,8 @@ router.get('/gh/cb', async ctx => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||||
|
const locale = locales[profile.lang || 'en-US'];
|
||||||
|
const i18n = new I18n(locale);
|
||||||
|
|
||||||
await UserProfiles.update(user.id, {
|
await UserProfiles.update(user.id, {
|
||||||
integrations: {
|
integrations: {
|
||||||
|
@ -246,7 +253,10 @@ router.get('/gh/cb', async ctx => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.body = `GitHub: @${login} connected to FoundKey: @${user.username}!`;
|
ctx.body = i18n.t('_services._github.connected', {
|
||||||
|
login,
|
||||||
|
userName: user.username,
|
||||||
|
});
|
||||||
|
|
||||||
// Publish i updated event
|
// Publish i updated event
|
||||||
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { Users, UserProfiles } from '@/models/index.js';
|
||||||
import { ILocalUser } from '@/models/entities/user.js';
|
import { ILocalUser } from '@/models/entities/user.js';
|
||||||
import { redisClient } from '@/db/redis.js';
|
import { redisClient } from '@/db/redis.js';
|
||||||
import signin from '../common/signin.js';
|
import signin from '../common/signin.js';
|
||||||
|
import { I18n } from '@/misc/i18n.js';
|
||||||
|
|
||||||
function getUserToken(ctx: Koa.BaseContext): string | null {
|
function getUserToken(ctx: Koa.BaseContext): string | null {
|
||||||
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||||
|
@ -25,6 +26,8 @@ function compareOrigin(ctx: Koa.BaseContext): boolean {
|
||||||
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
return (normalizeUrl(referer) === normalizeUrl(config.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const locales = await import('../../../../../../locales/index.js').then(mod => mod.default);
|
||||||
|
|
||||||
// Init router
|
// Init router
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
|
@ -46,6 +49,8 @@ router.get('/disconnect/twitter', async ctx => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||||
|
const locale = locales[profile.lang || 'en-US'];
|
||||||
|
const i18n = new I18n(locale);
|
||||||
|
|
||||||
delete profile.integrations.twitter;
|
delete profile.integrations.twitter;
|
||||||
|
|
||||||
|
@ -53,7 +58,7 @@ router.get('/disconnect/twitter', async ctx => {
|
||||||
integrations: profile.integrations,
|
integrations: profile.integrations,
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.body = 'Twitter linkage has been removed :v:';
|
ctx.body = i18n.t('_services._twitter.disconnected');
|
||||||
|
|
||||||
// Publish i updated event
|
// Publish i updated event
|
||||||
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
||||||
|
@ -175,6 +180,8 @@ router.get('/tw/cb', async ctx => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||||
|
const locale = locales[profile.lang || 'en-US'];
|
||||||
|
const i18n = new I18n(locale);
|
||||||
|
|
||||||
await UserProfiles.update(user.id, {
|
await UserProfiles.update(user.id, {
|
||||||
integrations: {
|
integrations: {
|
||||||
|
@ -188,7 +195,10 @@ router.get('/tw/cb', async ctx => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.body = `Twitter: @${result.screenName} connected to FoundKey: @${user.username}!`;
|
ctx.body = i18n.t('_services._twitter.connected', {
|
||||||
|
twitterUserName: result.screenName,
|
||||||
|
userName: user.username,
|
||||||
|
});
|
||||||
|
|
||||||
// Publish i updated event
|
// Publish i updated event
|
||||||
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
"noFallthroughCasesInSwitch": true,
|
"noFallthroughCasesInSwitch": true,
|
||||||
"declaration": false,
|
"declaration": false,
|
||||||
"sourceMap": false,
|
"sourceMap": false,
|
||||||
"target": "es2017",
|
"target": "ES2021",
|
||||||
"module": "es2020",
|
"module": "esnext",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
|
|
Loading…
Reference in a new issue