feat: ✨ Add "no language" option to language picker
This commit is contained in:
parent
e87b46863d
commit
8555496146
3 changed files with 13 additions and 4 deletions
|
@ -111,7 +111,7 @@ export const paramDef = {
|
|||
text: { type: "string", maxLength: MAX_NOTE_TEXT_LENGTH, nullable: true },
|
||||
lang: {
|
||||
type: "string",
|
||||
enum: Object.keys(langmap),
|
||||
enum: [null, ...Object.keys(langmap)],
|
||||
nullable: true,
|
||||
},
|
||||
cw: { type: "string", nullable: true, maxLength: 100 },
|
||||
|
|
|
@ -171,7 +171,7 @@ export const paramDef = {
|
|||
text: { type: "string", maxLength: MAX_NOTE_TEXT_LENGTH, nullable: true },
|
||||
lang: {
|
||||
type: "string",
|
||||
enum: Object.keys(langmap),
|
||||
enum: [null, ...Object.keys(langmap)],
|
||||
nullable: true,
|
||||
},
|
||||
cw: { type: "string", nullable: true, maxLength: 250 },
|
||||
|
|
|
@ -708,7 +708,7 @@ function setVisibility() {
|
|||
);
|
||||
}
|
||||
|
||||
const language = ref<string>(
|
||||
const language = ref<string | null>(
|
||||
props.initialLanguage ??
|
||||
defaultStore.state.recentlyUsedPostLanguages[0] ??
|
||||
localStorage.getItem("lang")?.split("-")[0],
|
||||
|
@ -717,7 +717,7 @@ const language = ref<string>(
|
|||
function filterLangmapByPrefix(
|
||||
prefix: string,
|
||||
): { langCode: string; nativeName: string }[] {
|
||||
const to_return = Object.entries(langmap)
|
||||
let to_return = Object.entries(langmap)
|
||||
.filter(([langCode, _]) => langCode.startsWith(prefix))
|
||||
.map(([langCode, v]) => {
|
||||
return { langCode, nativeName: v.nativeName };
|
||||
|
@ -781,6 +781,15 @@ function setLanguage() {
|
|||
}
|
||||
if (recentlyUsedLanguagesExist) actions.push(null);
|
||||
|
||||
actions.push({
|
||||
text: i18n.ts.noLanguage,
|
||||
danger: false,
|
||||
active: false,
|
||||
action: () => {
|
||||
language.value = null;
|
||||
},
|
||||
});
|
||||
|
||||
for (const lang of langs) {
|
||||
if (lang === language.value) continue;
|
||||
if (defaultStore.state.recentlyUsedPostLanguages.includes(lang))
|
||||
|
|
Loading…
Reference in a new issue