backend: localize strings for service integrations
Some checks failed
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/test Pipeline failed

Currently only the 'connected' and 'disconnected' strings are translated.
This commit is contained in:
Norm 2022-09-13 13:12:42 -04:00
parent 57f4312a27
commit e507b1b888
6 changed files with 59 additions and 8 deletions

View file

@ -1409,3 +1409,13 @@ _deck:
list: "List"
mentions: "Mentions"
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:"

View file

@ -1452,3 +1452,13 @@ _deck:
list: "リスト"
mentions: "あなた宛て"
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:"

View file

@ -10,6 +10,7 @@ import { fetchMeta } from '@/misc/fetch-meta.js';
import { Users, UserProfiles } from '@/models/index.js';
import { ILocalUser } from '@/models/entities/user.js';
import { redisClient } from '@/db/redis.js';
import { I18n } from '@/misc/i18n.js';
import signin from '../common/signin.js';
function getUserToken(ctx: Koa.BaseContext): string | null {
@ -26,6 +27,8 @@ function compareOrigin(ctx: Koa.BaseContext): boolean {
return (normalizeUrl(referer) === normalizeUrl(config.url));
}
const locales = await import('../../../../../../locales/index.js').then(mod => mod.default);
// Init router
const router = new Router();
@ -47,6 +50,8 @@ router.get('/disconnect/discord', async ctx => {
});
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
const locale = locales[profile.lang || 'en-US'];
const i18n = new I18n(locale);
delete profile.integrations.discord;
@ -54,7 +59,7 @@ router.get('/disconnect/discord', async ctx => {
integrations: profile.integrations,
});
ctx.body = 'Discordの連携を解除しました :v:';
ctx.body = i18n.t('_services._discord.disconnected');
// Publish i updated event
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 locale = locales[profile.lang || 'en-US'];
const i18n = new I18n(locale);
await UserProfiles.update(user.id, {
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
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {

View file

@ -11,6 +11,7 @@ import { Users, UserProfiles } from '@/models/index.js';
import { ILocalUser } from '@/models/entities/user.js';
import { redisClient } from '@/db/redis.js';
import signin from '../common/signin.js';
import { I18n } from '@/misc/i18n.js';
function getUserToken(ctx: Koa.BaseContext): string | null {
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));
}
const locales = await import('../../../../../../locales/index.js').then(mod => mod.default);
// Init router
const router = new Router();
@ -47,6 +50,8 @@ router.get('/disconnect/github', async ctx => {
});
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
const locale = locales[profile.lang || 'en-US'];
const i18n = new I18n(locale);
delete profile.integrations.github;
@ -54,7 +59,7 @@ router.get('/disconnect/github', async ctx => {
integrations: profile.integrations,
});
ctx.body = 'GitHubの連携を解除しました :v:';
ctx.body = i18n.t('_services._github.disconnected');
// Publish i updated event
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 locale = locales[profile.lang || 'en-US'];
const i18n = new I18n(locale);
await UserProfiles.update(user.id, {
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
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {

View file

@ -10,6 +10,7 @@ import { Users, UserProfiles } from '@/models/index.js';
import { ILocalUser } from '@/models/entities/user.js';
import { redisClient } from '@/db/redis.js';
import signin from '../common/signin.js';
import { I18n } from '@/misc/i18n.js';
function getUserToken(ctx: Koa.BaseContext): string | null {
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));
}
const locales = await import('../../../../../../locales/index.js').then(mod => mod.default);
// Init router
const router = new Router();
@ -46,6 +49,8 @@ router.get('/disconnect/twitter', async ctx => {
});
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
const locale = locales[profile.lang || 'en-US'];
const i18n = new I18n(locale);
delete profile.integrations.twitter;
@ -53,7 +58,7 @@ router.get('/disconnect/twitter', async ctx => {
integrations: profile.integrations,
});
ctx.body = 'Twitter linkage has been removed :v:';
ctx.body = i18n.t('_services._twitter.disconnected');
// Publish i updated event
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 locale = locales[profile.lang || 'en-US'];
const i18n = new I18n(locale);
await UserProfiles.update(user.id, {
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
publishMainStream(user.id, 'meUpdated', await Users.pack(user, user, {

View file

@ -10,8 +10,8 @@
"noFallthroughCasesInSwitch": true,
"declaration": false,
"sourceMap": false,
"target": "es2017",
"module": "es2020",
"target": "ES2021",
"module": "esnext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"removeComments": false,