Skip to content

Commit

Permalink
Improve: Extract language proficiencies (#59)
Browse files Browse the repository at this point in the history
 - Extract language proficiencies (profile section), and combine with
 main profile default locale (might lead to duplicates, but this kind
 of unavoidable)
  • Loading branch information
joshuatz committed Nov 8, 2021
1 parent d0b941f commit 35cba20
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ declare global {
parseSuccess: boolean;
sections: {
basics: CaptureResult;
languages: CaptureResult;
attachments: CaptureResult;
education: CaptureResult;
work: CaptureResult;
Expand Down
39 changes: 38 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ window.LinkedinToResumeJson = (() => {
parseSuccess: false,
sections: {
basics: 'fail',
languages: 'fail',
attachments: 'fail',
education: 'fail',
work: 'fail',
Expand Down Expand Up @@ -492,7 +493,7 @@ window.LinkedinToResumeJson = (() => {
};
/** @type {ResumeSchemaLegacy['languages'][0]} */
const formatttedLang = {
language: localeObject.language,
language: localeObject.language.toLowerCase() === 'en' ? 'English' : localeObject.language,
fluency: 'Native Speaker'
};
_outputJsonLegacy.languages.push(formatttedLang);
Expand All @@ -506,6 +507,42 @@ window.LinkedinToResumeJson = (() => {
}
});

// Parse languages (in _addition_ to the core profile language)
/** @type {ResumeSchemaStable['languages']} */
let languages = [];
const languageElements = db.getValuesByKey(_liTypeMappings.languages.tocKeys);
languageElements.forEach((languageMeta) => {
/** @type {Record<string,string>} */
const liProficiencyEnumToJsonResumeStr = {
NATIVE_OR_BILINGUAL: 'Native Speaker',
FULL_PROFESSIONAL: 'Full Professional',
EXPERT: 'Expert',
ADVANCED: 'Advanced',
PROFESSIONAL_WORKING: 'Professional Working',
LIMITED_WORKING: 'Limited Working',
INTERMEDIATE: 'intermediate',
BEGINNER: 'Beginner',
ELEMENTARY: 'Elementary'
};
const liProficiency = typeof languageMeta.proficiency === 'string' ? languageMeta.proficiency.toUpperCase() : undefined;
if (liProficiency && liProficiency in liProficiencyEnumToJsonResumeStr) {
languages.push({
fluency: liProficiencyEnumToJsonResumeStr[liProficiency],
language: languageMeta.name
});
}
});
// Merge with main profile language, while preventing duplicate
languages = [
..._outputJsonStable.languages.filter((e) => {
return !languages.find((l) => l.language === e.language);
}),
...languages
];
_outputJsonLegacy.languages = languages;
_outputJsonStable.languages = languages;
resultSummary.sections.languages = languages.length ? 'success' : 'empty';

// Parse attachments / portfolio links
const attachments = db.getValuesByKey(_liTypeMappings.attachments.tocKeys);
attachments.forEach((attachment) => {
Expand Down
4 changes: 4 additions & 0 deletions src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const liTypeMappings = {
],
recipes: ['com.linkedin.voyager.dash.deco.identity.profile.FullProfileWithEntities']
},
languages: {
tocKeys: ['*languageView'],
types: ['com.linkedin.voyager.identity.profile.Language']
},
certificates: {
tocKeys: ['*certificationView', '*profileCertifications'],
types: ['com.linkedin.voyager.dash.identity.profile.Certification'],
Expand Down

0 comments on commit 35cba20

Please sign in to comment.