fix using wrong langmap for post lang
Some checks failed
Lint / pnpm_install (pull_request) Successful in 32s
API report (misskey.js) / report (pull_request) Successful in 46s
Test (misskey.js) / test (22.x) (pull_request) Successful in 49s
Test (frontend) / vitest (22.x) (pull_request) Successful in 1m24s
Test (production install and build) / production (22.x) (pull_request) Successful in 1m4s
Test (backend) / unit (22.x) (pull_request) Successful in 2m31s
Test (backend) / validate-api-json (22.x) (pull_request) Successful in 1m28s
Lint / lint (backend) (pull_request) Failing after 59s
Lint / lint (misskey-js) (pull_request) Failing after 32s
Lint / lint (sw) (pull_request) Successful in 35s
Lint / typecheck (misskey-js) (pull_request) Successful in 34s
Lint / typecheck (backend) (pull_request) Failing after 1m20s
Test (backend) / e2e (22.x) (pull_request) Failing after 6m33s
Lint / lint (frontend) (pull_request) Failing after 7m19s

This commit is contained in:
Leah 2025-02-05 17:33:07 +01:00
parent 637f10f2a2
commit 760055bcc2
6 changed files with 637 additions and 9 deletions

View file

@ -72,7 +72,7 @@ import { trackPromise } from '@/misc/promise-tracker.js';
import { isNotNull } from '@/misc/is-not-null.js';
import { IdentifiableError } from '@/misc/identifiable-error.js';
import { CollapsedQueue } from '@/misc/collapsed-queue.js';
import {langmap} from "@/misc/langmap.js";
import { SUPPORTED_POST_LOCALES } from "@/misc/langmap.js";
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
@ -344,7 +344,7 @@ export class NoteCreateService implements OnApplicationShutdown {
}
if (data.lang) {
if (!Object.keys(langmap).includes(data.lang.toLowerCase())) {
if (!Object.keys(SUPPORTED_POST_LOCALES).includes(data.lang.toLowerCase())) {
throw new Error("invalid lang param");
}
data.lang = data.lang.toLowerCase();

View file

@ -669,3 +669,631 @@ export const langmap = {
nativeName: 'isiZulu',
},
};
export const ISO_639_1 = {
aa: {
nativeName: 'Afaraf',
},
ab: {
nativeName: 'аҧсуа бызшәа',
},
ae: {
nativeName: 'avesta',
},
af: {
nativeName: 'Afrikaans',
},
ak: {
nativeName: 'Akan',
},
am: {
nativeName: 'አማርኛ',
},
an: {
nativeName: 'aragonés',
},
ar: {
nativeName: 'اللغة العربية',
},
as: {
nativeName: 'অসমীয়া',
},
av: {
nativeName: 'авар мацӀ',
},
ay: {
nativeName: 'aymar aru',
},
az: {
nativeName: 'azərbaycan dili',
},
ba: {
nativeName: 'башҡорт теле',
},
be: {
nativeName: 'беларуская мова',
},
bg: {
nativeName: 'български език',
},
bh: {
nativeName: 'भोजपुरी',
},
bi: {
nativeName: 'Bislama',
},
bm: {
nativeName: 'bamanankan',
},
bn: {
nativeName: 'বাংলা',
},
bo: {
nativeName: 'བོད་ཡིག',
},
br: {
nativeName: 'brezhoneg',
},
bs: {
nativeName: 'bosanski jezik',
},
ca: {
nativeName: 'Català',
},
ce: {
nativeName: 'нохчийн мотт',
},
ch: {
nativeName: 'Chamoru',
},
co: {
nativeName: 'corsu',
},
cr: {
nativeName: 'ᓀᐦᐃᔭᐍᐏᐣ',
},
cs: {
nativeName: 'čeština',
},
cu: {
nativeName: 'ѩзыкъ словѣньскъ',
},
cv: {
nativeName: 'чӑваш чӗлхи',
},
cy: {
nativeName: 'Cymraeg',
},
da: {
nativeName: 'dansk',
},
de: {
nativeName: 'Deutsch',
},
dv: {
nativeName: 'Dhivehi',
},
dz: {
nativeName: 'རྫོང་ཁ',
},
ee: {
nativeName: 'Eʋegbe',
},
el: {
nativeName: 'Ελληνικά',
},
en: {
nativeName: 'English',
},
eo: {
nativeName: 'Esperanto',
},
es: {
nativeName: 'Español',
},
et: {
nativeName: 'eesti',
},
eu: {
nativeName: 'euskara',
},
fa: {
nativeName: 'فارسی',
},
ff: {
nativeName: 'Fulfulde',
},
fi: {
nativeName: 'suomi',
},
fj: {
nativeName: 'Vakaviti',
},
fo: {
nativeName: 'føroyskt',
},
fr: {
nativeName: 'Français',
},
fy: {
nativeName: 'Frysk',
},
ga: {
nativeName: 'Gaeilge',
},
gd: {
nativeName: 'Gàidhlig',
},
gl: {
nativeName: 'galego',
},
gu: {
nativeName: 'ગુજરાતી',
},
gv: {
nativeName: 'Gaelg',
},
ha: {
nativeName: 'هَوُسَ',
},
he: {
nativeName: 'עברית',
},
hi: {
nativeName: 'हिन्दी',
},
ho: {
nativeName: 'Hiri Motu',
},
hr: {
nativeName: 'Hrvatski',
},
ht: {
nativeName: 'Kreyòl ayisyen',
},
hu: {
nativeName: 'magyar',
},
hy: {
nativeName: 'Հայերեն',
},
hz: {
nativeName: 'Otjiherero',
},
ia: {
nativeName: 'Interlingua',
},
id: {
nativeName: 'Bahasa Indonesia',
},
ie: {
nativeName: 'Interlingue',
},
ig: {
nativeName: 'Asụsụ Igbo',
},
ii: {
nativeName: 'ꆈꌠ꒿ Nuosuhxop',
},
ik: {
nativeName: 'Iñupiaq',
},
io: {
nativeName: 'Ido',
},
is: {
nativeName: 'Íslenska',
},
it: {
nativeName: 'Italiano',
},
iu: {
nativeName: 'ᐃᓄᒃᑎᑐᑦ',
},
ja: {
nativeName: '日本語',
},
jv: {
nativeName: 'basa Jawa',
},
ka: {
nativeName: 'ქართული',
},
kg: {
nativeName: 'Kikongo',
},
ki: {
nativeName: 'Gĩkũyũ',
},
kj: {
nativeName: 'Kuanyama',
},
kk: {
nativeName: 'қазақ тілі',
},
kl: {
nativeName: 'kalaallisut',
},
km: {
nativeName: 'ខេមរភាសា',
},
kn: {
nativeName: 'ಕನ್ನಡ',
},
ko: {
nativeName: '한국어',
},
kr: {
nativeName: 'Kanuri',
},
ks: {
nativeName: 'कश्मीरी',
},
ku: {
nativeName: 'Kurmancî',
},
kv: {
nativeName: 'коми кыв',
},
kw: {
nativeName: 'Kernewek',
},
ky: {
nativeName: 'Кыргызча',
},
la: {
nativeName: 'latine',
},
lb: {
nativeName: 'Lëtzebuergesch',
},
lg: {
nativeName: 'Luganda',
},
li: {
nativeName: 'Limburgs',
},
ln: {
nativeName: 'Lingála',
},
lo: {
nativeName: 'ລາວ',
},
lt: {
nativeName: 'lietuvių kalba',
},
lu: {
nativeName: 'Tshiluba',
},
lv: {
nativeName: 'latviešu valoda',
},
mg: {
nativeName: 'fiteny malagasy',
},
mh: {
nativeName: 'Kajin M̧ajeļ',
},
mi: {
nativeName: 'te reo Māori',
},
mk: {
nativeName: 'македонски јазик',
},
ml: {
nativeName: 'മലയാളം',
},
mn: {
nativeName: 'Монгол хэл',
},
mr: {
nativeName: 'मराठी',
},
ms: {
nativeName: 'Bahasa Melayu',
},
'ms-Arab': {
nativeName: 'بهاس ملايو',
},
mt: {
nativeName: 'Malti',
},
my: {
nativeName: 'ဗမာစာ',
},
na: {
nativeName: 'Ekakairũ Naoero',
},
nb: {
nativeName: 'Norsk bokmål',
},
nd: {
nativeName: 'isiNdebele',
},
ne: {
nativeName: 'नेपाली',
},
ng: {
nativeName: 'Owambo',
},
nl: {
nativeName: 'Nederlands',
},
nn: {
nativeName: 'Norsk Nynorsk',
},
no: {
nativeName: 'Norsk',
},
nr: {
nativeName: 'isiNdebele',
},
nv: {
nativeName: 'Diné bizaad',
},
ny: {
nativeName: 'chiCheŵa',
},
oc: {
nativeName: 'occitan',
},
oj: {
nativeName: 'ᐊᓂᔑᓈᐯᒧᐎᓐ',
},
om: {
nativeName: 'Afaan Oromoo',
},
or: {
nativeName: 'ଓଡ଼ିଆ',
},
os: {
nativeName: 'ирон æвзаг',
},
pa: {
nativeName: 'ਪੰਜਾਬੀ',
},
pi: {
nativeName: 'पाऴि',
},
pl: {
nativeName: 'Polski',
},
ps: {
nativeName: 'پښتو',
},
pt: {
nativeName: 'Português',
},
qu: {
nativeName: 'Runa Simi',
},
rm: {
nativeName: 'rumantsch grischun',
},
rn: {
nativeName: 'Ikirundi',
},
ro: {
nativeName: 'Română',
},
ru: {
nativeName: 'Русский',
},
rw: {
nativeName: 'Ikinyarwanda',
},
sa: {
nativeName: 'संस्कृतम्',
},
sc: {
nativeName: 'sardu',
},
sd: {
nativeName: 'सिन्धी',
},
se: {
nativeName: 'Davvisámegiella',
},
sg: {
nativeName: 'yângâ tî sängö',
},
si: {
nativeName: 'සිංහල',
},
sk: {
nativeName: 'slovenčina',
},
sl: {
nativeName: 'slovenščina',
},
sn: {
nativeName: 'chiShona',
},
so: {
nativeName: 'Soomaaliga',
},
sq: {
nativeName: 'Shqip',
},
sr: {
nativeName: 'српски језик',
},
ss: {
nativeName: 'SiSwati',
},
st: {
nativeName: 'Sesotho',
},
su: {
nativeName: 'Basa Sunda',
},
sv: {
nativeName: 'Svenska',
},
sw: {
nativeName: 'Kiswahili',
},
ta: {
nativeName: 'தமிழ்',
},
te: {
nativeName: 'తెలుగు',
},
tg: {
nativeName: 'тоҷикӣ',
},
th: {
nativeName: 'ไทย',
},
ti: {
nativeName: 'ትግርኛ',
},
tk: {
nativeName: 'Türkmen',
},
tl: {
nativeName: 'Tagalog',
},
tn: {
nativeName: 'Setswana',
},
to: {
nativeName: 'faka Tonga',
},
tr: {
nativeName: 'Türkçe',
},
ts: {
nativeName: 'Xitsonga',
},
tt: {
nativeName: 'татар теле',
},
tw: {
nativeName: 'Twi',
},
ty: {
nativeName: 'Reo Tahiti',
},
ug: {
nativeName: 'ئۇيغۇرچە‎',
},
uk: {
nativeName: 'Українська',
},
ur: {
nativeName: 'اردو',
},
vi: {
nativeName: 'Tiếng Việt',
},
vo: {
nativeName: 'Volapük',
},
wa: {
nativeName: 'Walon',
},
wo: {
nativeName: 'Wollof',
},
xh: {
nativeName: 'isiXhosa',
},
yi: {
nativeName: 'ייִדיש',
},
zu: {
nativeName: 'isiZulu',
},
};
export const ISO_639_3 = {
ast: {
nativeName: 'Asturianu',
},
chr: {
nativeName: 'ᏣᎳᎩ ᎦᏬᏂᎯᏍᏗ',
},
ckb: {
nativeName: 'سۆرانی',
},
cnr: {
nativeName: 'crnogorski',
},
csb: {
nativeName: 'Kaszëbsczi',
},
gsw: {
nativeName: 'Schwiizertütsch',
},
jbo: {
nativeName: 'la .lojban.',
},
kab: {
nativeName: 'Taqbaylit',
},
ldn: {
nativeName: 'Láadan',
},
lfn: {
nativeName: 'lingua franca nova',
},
moh: {
nativeName: 'Kanienʼkéha',
},
nds: {
nativeName: 'Plattdüütsch',
},
pdc: {
nativeName: 'Pennsilfaani-Deitsch',
},
sco: {
nativeName: 'Scots',
},
sma: {
nativeName: 'Åarjelsaemien Gïele',
},
smj: {
nativeName: 'Julevsámegiella',
},
szl: {
nativeName: 'ślůnsko godka',
},
tok: {
nativeName: 'toki pona',
},
vai: {
nativeName: 'ꕙꔤ',
},
xal: {
nativeName: 'Хальмг келн',
},
zba: {
nativeName: 'باليبلن',
},
zgh: {
nativeName: 'ⵜⴰⵎⴰⵣⵉⵖⵜ',
},
};
export const ISO_639_1_REGIONAL = {
'zh-CN': {
nativeName: '简体中文',
},
'zh-HK': {
nativeName: '繁體中文(香港)',
},
'zh-TW': {
nativeName: '繁體中文(臺灣)',
},
'zh-YUE': {
nativeName: '廣東話',
},
};
export const SUPPORTED_POST_LOCALES = {
...ISO_639_1,
...ISO_639_3,
...ISO_639_1_REGIONAL,
};

View file

@ -2,7 +2,7 @@
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { langmap } from "@/misc/langmap.js";
import { SUPPORTED_POST_LOCALES } from "@/misc/langmap.js";
export const packedNoteSchema = {
type: 'object',
@ -29,7 +29,7 @@ export const packedNoteSchema = {
},
lang: {
type: 'string',
enum: [...Object.keys(langmap)],
enum: [...Object.keys(SUPPORTED_POST_LOCALES)],
nullable: true,
},
cw: {

View file

@ -16,7 +16,7 @@ import type { MiLocalUser, MiUser } from '@/models/User.js';
import { birthdaySchema, descriptionSchema, locationSchema, nameSchema } from '@/models/User.js';
import type { MiUserProfile } from '@/models/UserProfile.js';
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
import { langmap } from '@/misc/langmap.js';
import { SUPPORTED_POST_LOCALES } from '@/misc/langmap.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
@ -150,7 +150,7 @@ export const paramDef = {
description: { ...descriptionSchema, nullable: true },
location: { ...locationSchema, nullable: true },
birthday: { ...birthdaySchema, nullable: true },
lang: { type: 'string', enum: [null, ...Object.keys(langmap)] as string[], nullable: true },
lang: { type: 'string', enum: [null, ...Object.keys(SUPPORTED_POST_LOCALES)] as string[], nullable: true },
avatarId: { type: 'string', format: 'misskey:id', nullable: true },
avatarDecorations: { type: 'array', maxItems: 16, items: {
type: 'object',

View file

@ -23,7 +23,7 @@ import { isQuote, isRenote } from '@/misc/is-renote.js';
import { IdentifiableError } from '@/misc/identifiable-error.js';
import { LoggerService } from '@/core/LoggerService.js';
import { ApiError } from '../../error.js';
import {langmap} from "@/misc/langmap.js";
import { SUPPORTED_POST_LOCALES } from "@/misc/langmap.js";
export const meta = {
tags: ['notes'],
@ -213,7 +213,7 @@ export const paramDef = {
},
lang: {
type: "string",
enum: Object.keys(langmap),
enum: Object.keys(SUPPORTED_POST_LOCALES),
nullable: true,
},
fileIds: {