add meta.locale in jsoncv schema, use it when rendering the theme
This commit is contained in:
parent
44808bf31e
commit
911df68cd1
|
|
@ -280,6 +280,8 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"meta": {
|
"meta": {
|
||||||
|
"name": "JSONCV Sample Resume",
|
||||||
|
"locale": "en",
|
||||||
"canonical": "https://raw.githubusercontent.com/reorx/jsoncv/master/schema/jsoncv.schema.json",
|
"canonical": "https://raw.githubusercontent.com/reorx/jsoncv/master/schema/jsoncv.schema.json",
|
||||||
"version": "v2.0.0",
|
"version": "v2.0.0",
|
||||||
"lastModified": "2023-02-12T22:26:00"
|
"lastModified": "2023-02-12T22:26:00"
|
||||||
|
|
|
||||||
|
|
@ -509,6 +509,10 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The name of this JSONCV data, will be used as part of the filename when downloading."
|
"description": "The name of this JSONCV data, will be used as part of the filename when downloading."
|
||||||
},
|
},
|
||||||
|
"locale": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Locale of the CV, used by the theme to localize the CV. The value must be a valid IETF language tag. Default to 'en' if not specified. A full list of locale tag can be found at: https://cdn.jsdelivr.net/npm/dayjs@1/locale.json"
|
||||||
|
},
|
||||||
"canonical": {
|
"canonical": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "URL (as per RFC 3986) to latest version of this document",
|
"description": "URL (as per RFC 3986) to latest version of this document",
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import { getCVTitle } from '../themes/data';
|
||||||
import { registerIconLib } from './je-iconlib';
|
import { registerIconLib } from './je-iconlib';
|
||||||
import { registerTheme } from './je-theme';
|
import { registerTheme } from './je-theme';
|
||||||
|
|
||||||
const propertiesInOrder = ['basics', 'education', 'work', 'projects', 'sideProjects', 'skills', 'languages', 'interests', 'references', 'awards', 'publications', 'volunteer', 'certificates', 'meta']
|
const propertiesInOrder = ['meta', 'basics', 'education', 'work', 'projects', 'sideProjects', 'skills', 'languages', 'interests', 'references', 'awards', 'publications', 'volunteer', 'certificates']
|
||||||
const basicsPropertiesInOrder = ['name', 'label', 'email', 'phone', 'url', 'summary', 'image', 'location', 'profiles']
|
const basicsPropertiesInOrder = ['name', 'label', 'email', 'phone', 'url', 'summary', 'image', 'location', 'profiles']
|
||||||
|
|
||||||
// toc elements
|
// toc elements
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,15 @@ export function getTheme(name) {
|
||||||
return themes[name]
|
return themes[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderTheme(theme, cvData, locale, options) {
|
export function renderTheme(theme, cvData, options) {
|
||||||
|
const locale = cvData.meta.locale || 'en'
|
||||||
|
const messages = theme.index.localeMessages[locale]
|
||||||
|
if (!messages) {
|
||||||
|
return `Error: locale '${locale}' is not supported, please use one of: ${theme.index.locales}`
|
||||||
|
}
|
||||||
const polyglot = new Polyglot({
|
const polyglot = new Polyglot({
|
||||||
phrases: theme.index.localeMessages[locale],
|
phrases: messages,
|
||||||
|
locale,
|
||||||
})
|
})
|
||||||
dayjs.locale(locale)
|
dayjs.locale(locale)
|
||||||
return ejs.render(theme.template, getRenderData(cvData, locale, polyglot), options)
|
return ejs.render(theme.template, getRenderData(cvData, locale, polyglot), options)
|
||||||
|
|
@ -52,7 +58,7 @@ const cvStyleId = 'cv-style'
|
||||||
|
|
||||||
export function renderThemeOn(name, el, data, primaryColor) {
|
export function renderThemeOn(name, el, data, primaryColor) {
|
||||||
const theme = getTheme(name)
|
const theme = getTheme(name)
|
||||||
el.innerHTML = renderTheme(theme, data, 'zh-cn')
|
el.innerHTML = renderTheme(theme, data)
|
||||||
|
|
||||||
upsertStyleTag(cvStyleId, theme.style)
|
upsertStyleTag(cvStyleId, theme.style)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue