(langs: string[])
| 22 | |
| 23 | // Look for the origin language by alias |
| 24 | export function transformAliasToOrigin(langs: string[]) { |
| 25 | const result = []; |
| 26 | |
| 27 | for (const lang of langs) { |
| 28 | if (languages[lang]) { |
| 29 | result.push(lang); |
| 30 | } |
| 31 | else { |
| 32 | const language = Object.keys(languages).find((name) => { |
| 33 | const l = languages[name]; |
| 34 | if (l.alias) { |
| 35 | return ( |
| 36 | l.alias === lang |
| 37 | || (Array.isArray(l.alias) && l.alias.includes(lang)) |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | return false; |
| 42 | }); |
| 43 | |
| 44 | if (language) { |
| 45 | result.push(language); |
| 46 | } |
| 47 | else { |
| 48 | // The lang is not exist, the will handle in `initLoadLanguage` |
| 49 | result.push(lang); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return result; |
| 55 | } |
| 56 | |
| 57 | // Minimal Prism surface this module needs — full Prism typings live in |
| 58 | // prismjs's external @types package, but we only read `languages` here. |
no test coverage detected