#760 - Windows file path fixes in multilingual

This commit is contained in:
Elio Struyf
2024-02-24 13:46:26 +01:00
parent b02a80c28e
commit c298f2fd69
7 changed files with 43 additions and 15 deletions
+1
View File
@@ -698,6 +698,7 @@
"helpers.questions.selectContentType.quickPick.title": "Content type",
"helpers.questions.selectContentType.quickPick.placeholder": "Select the content type to create your new content",
"helpers.questions.selectContentType.noSelection.warning": "No content type was selected.",
"helpers.questions.selectContentType.quickPick.error.noContentTypes": "There are no matching content types configured for this folder.",
"helpers.seoHelper.checkLength.diagnostic.message": "Article {0} is longer than {1} characters (current length: {2}). For SEO reasons, it would be better to make it less than {1} characters.",
+3 -3
View File
@@ -99,7 +99,7 @@ export class Folders {
}
const folders = Folders.get().filter((f) => !f.disableCreation);
const location = folders.find((f) => f.title === selectedFolder);
const location = folders.find((f) => f.path === selectedFolder.path);
if (location) {
const folderPath = Folders.getFolderPath(Uri.file(location.path));
if (folderPath) {
@@ -370,7 +370,7 @@ export class Folders {
locale: i18n.locale,
localeTitle: i18n?.title || i18n.locale,
localeSourcePath: sourcePath,
path: join(folderPath, i18n.path)
path: parseWinPath(join(folderPath, i18n.path))
});
}
}
@@ -383,7 +383,7 @@ export class Folders {
localeTitle: defaultLocale?.title || folder.defaultLocale,
originalPath: folder.path,
localeSourcePath: sourcePath,
path: join(folderPath, defaultLocale?.path || '')
path: parseWinPath(join(folderPath, defaultLocale?.path || ''))
});
contentFolders.push(...localeFolders);
+2 -1
View File
@@ -424,7 +424,8 @@ export class i18n {
);
if (!translations || translations.length < 3) {
throw new Error('Invalid response');
resolve(article);
return;
}
article.data.title = article.data.title ? translations[0] : '';
+1 -1
View File
@@ -95,7 +95,7 @@ export class ContentType {
const contentTypes = ContentType.getAll();
const folders = Folders.get().filter((f) => !f.disableCreation);
const folder = folders.find((f) => f.title === selectedFolder);
const folder = folders.find((f) => f.path === selectedFolder.path);
if (!folder) {
return;
+31 -9
View File
@@ -10,6 +10,11 @@ import * as l10n from '@vscode/l10n';
import { LocalizationKey } from '../localization';
import { ContentFolder } from '../models';
interface FolderQuickPickItem extends QuickPickItem {
path: string;
locale?: string;
}
export class Questions {
/**
* Yes/No question
@@ -125,18 +130,27 @@ export class Questions {
*/
public static async SelectContentFolder(
showWarning: boolean = true
): Promise<string | undefined> {
): Promise<FolderQuickPickItem | undefined> {
let folders = Folders.get().filter((f) => !f.disableCreation);
let selectedFolder: string | undefined;
let selectedFolder: FolderQuickPickItem | undefined;
if (folders.length > 1) {
const folderOptions = folders.map((f: ContentFolder) => {
if (f.locale) {
return {
label: `${f.title} (${f.localeTitle || f.locale})`,
locale: f.locale,
path: f.path
} as FolderQuickPickItem;
}
return {
label: f.title,
path: f.path
} as FolderQuickPickItem;
});
selectedFolder = await window.showQuickPick(
folders.map((f: ContentFolder) => {
if (f.locale) {
return `${f.title} (${f.localeTitle || f.locale})`;
}
return f.title;
}),
folderOptions,
{
title: l10n.t(LocalizationKey.helpersQuestionsSelectContentFolderQuickPickTitle),
placeHolder: l10n.t(
@@ -146,7 +160,10 @@ export class Questions {
}
);
} else if (folders.length === 1) {
selectedFolder = folders[0].title;
selectedFolder = {
label: folders[0].title,
path: folders[0].path
} as FolderQuickPickItem;
} else {
// When no page folders are found, the welcome dashboard is shown
return;
@@ -195,6 +212,11 @@ export class Questions {
label: contentType.name
}));
if (options.length === 0) {
Notifications.error(LocalizationKey.helpersQuestionsSelectContentTypeQuickPickErrorNoContentTypes);
return;
}
const selectedOption = await window.showQuickPick(options, {
title: l10n.t(LocalizationKey.helpersQuestionsSelectContentTypeQuickPickTitle),
placeHolder: l10n.t(LocalizationKey.helpersQuestionsSelectContentTypeQuickPickPlaceholder),
+4
View File
@@ -2296,6 +2296,10 @@ export enum LocalizationKey {
* No content type was selected.
*/
helpersQuestionsSelectContentTypeNoSelectionWarning = 'helpers.questions.selectContentType.noSelection.warning',
/**
* There are no matching content types configured for this folder.
*/
helpersQuestionsSelectContentTypeQuickPickErrorNoContentTypes = 'helpers.questions.selectContentType.quickPick.error.noContentTypes',
/**
* Article {0} is longer than {1} characters (current length: {2}). For SEO reasons, it would be better to make it less than {1} characters.
*/
@@ -29,7 +29,7 @@ const FolderAndFiles: React.FunctionComponent<IFolderAndFilesProps> = ({
{folder.lastModified ? (
<div key={`${folder.title}-${idx}`}>
<FileList
folderName={folder.localeTitle ? `${folder.title} (${folder.localeTitle})` : folder.title}
folderName={folder.locale ? `${folder.title} (${folder.localeTitle || folder.locale})` : folder.title}
totalFiles={folder.files}
files={folder.lastModified}
/>