npm 연습하기
2.franc & langs 설치하기
franc : https://github.com/wooorm/franc/tree/main
langs : https://github.com/adlawson/nodejs-langs
package.json 파일 dependency에 라이브러리 정보가 입력됨
3.index.js 파일에 franc와 langs를 불러옴
노드 버전이 달라서 오류 발생
package.json에 type:"module" 추가
require 대신 import로 사용
4.github에서 이 패키지들의 사용법을 숙지하고 사용
import {franc} from 'franc'
import langs from 'langs'
// console.log(langs.where("name", "Korean"));
const langName = franc('반갑습니다', {minLength:2}) //'kor'
const result =langs.where("3", langName)
console.log(result)
{
// '1': 'ko',
// '2': 'kor',
// '3': 'kor',
// name: 'Korean',
// local: '한국어',
// '2T': 'kor',
// '2B': 'kor'
// }
console.log(result.name);//"Korean";
import {franc} from 'franc'
import langs from 'langs'
const input = process.argv[2];
const langName = franc(input, {minLength:2})
console.log(langName);
const result =langs.where("3", langName)
console.log(result);