-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdefaultProjects.js
More file actions
65 lines (57 loc) · 1.46 KB
/
defaultProjects.js
File metadata and controls
65 lines (57 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import i18n from "./i18n";
const UNTITLED_PROJECT_NAME = "Untitled project";
export const defaultPythonProject = {
project_type: "python",
name: UNTITLED_PROJECT_NAME,
locale: null,
components: [{ extension: "py", name: "main", content: "", default: true }],
image_list: [],
};
export const defaultHtmlProject = {
project_type: "html",
name: UNTITLED_PROJECT_NAME,
components: [
{
extension: "html",
name: "index",
content: "",
},
{ extension: "css", name: "style", content: "" },
],
};
export const DEFAULT_PROJECTS = {
python: defaultPythonProject,
html: defaultHtmlProject,
};
export const createDefaultPythonProject = async (locale = i18n.language) => {
try {
if (locale && i18n.resolvedLanguage !== locale) {
await i18n.changeLanguage?.(locale);
}
} catch {
// Fall back to the default untitled name if locale files fail.
}
return {
...defaultPythonProject,
name: i18n.t("project.untitled", {
lng: locale,
defaultValue: UNTITLED_PROJECT_NAME,
}),
};
};
export const createDefaultHtmlProject = async (locale = i18n.language) => {
try {
if (locale && i18n.resolvedLanguage !== locale) {
await i18n.changeLanguage?.(locale);
}
} catch {
// Fall back to the default untitled name if locale files fail.
}
return {
...defaultHtmlProject,
name: i18n.t("project.untitled", {
lng: locale,
defaultValue: UNTITLED_PROJECT_NAME,
}),
};
};