From c2fc01971c74f3b18ea0965fd838248b857e276a Mon Sep 17 00:00:00 2001 From: oko_jin Date: Sat, 29 Mar 2025 15:00:06 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EC=97=AC=EB=9F=AC=20csv=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EC=9D=84=20=EC=9D=BD=EA=B3=A0=20json=EC=9D=84=20?= =?UTF-8?q?=EB=A7=8C=EB=93=A4=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #25 --- locales/en/common.json | 6 +- locales/en/mainPage.json | 6 ++ locales/ko/common.json | 6 +- locales/ko/mainPage.json | 6 ++ scripts/generateTranslations.js | 72 +++++++++++-------- translations/commonTranslations.csv | 8 +++ ...nslations.csv => mainPageTranslations.csv} | 7 -- 7 files changed, 63 insertions(+), 48 deletions(-) create mode 100644 locales/en/mainPage.json create mode 100644 locales/ko/mainPage.json create mode 100644 translations/commonTranslations.csv rename translations/{translations.csv => mainPageTranslations.csv} (60%) diff --git a/locales/en/common.json b/locales/en/common.json index 1314673..caf725c 100644 --- a/locales/en/common.json +++ b/locales/en/common.json @@ -5,9 +5,5 @@ "recruitmentInfo": "recruitment", "companiesInfo": "Companies", "nearBy": "Surrounding", - "community": "Community", - "mainBannerTitle1": "For foreigners", - "mainBannerTitle2": "recruitment platform", - "mainBannerSubtitle": "It provides customized employment information and services for foreigners looking for a job in Korea", - "viewRecruitment": "View Recruitment" + "community": "Community" } \ No newline at end of file diff --git a/locales/en/mainPage.json b/locales/en/mainPage.json new file mode 100644 index 0000000..e5ecca3 --- /dev/null +++ b/locales/en/mainPage.json @@ -0,0 +1,6 @@ +{ + "mainBannerTitle1": "For foreigners", + "mainBannerTitle2": "recruitment platform", + "mainBannerSubtitle": "It provides customized employment information and services for foreigners looking for a job in Korea", + "viewRecruitment": "View Recruitment" +} \ No newline at end of file diff --git a/locales/ko/common.json b/locales/ko/common.json index 29da76e..637c2d2 100644 --- a/locales/ko/common.json +++ b/locales/ko/common.json @@ -5,9 +5,5 @@ "recruitmentInfo": "채용정보", "companiesInfo": "기업정보", "nearBy": "주변기업찾기", - "community": "커뮤니티", - "mainBannerTitle1": "외국인을 위한", - "mainBannerTitle2": "채용 플랫폼", - "mainBannerSubtitle": "한국에서 일자리를 찾고 있는 외국인을 위한 맞춤형 취업 정보와 서비스를 제공합니다", - "viewRecruitment": "채용정보 보기" + "community": "커뮤니티" } \ No newline at end of file diff --git a/locales/ko/mainPage.json b/locales/ko/mainPage.json new file mode 100644 index 0000000..ab11a38 --- /dev/null +++ b/locales/ko/mainPage.json @@ -0,0 +1,6 @@ +{ + "mainBannerTitle1": "외국인을 위한", + "mainBannerTitle2": "채용 플랫폼", + "mainBannerSubtitle": "한국에서 일자리를 찾고 있는 외국인을 위한 맞춤형 취업 정보와 서비스를 제공합니다", + "viewRecruitment": "채용정보 보기" +} \ No newline at end of file diff --git a/scripts/generateTranslations.js b/scripts/generateTranslations.js index b799635..017dc29 100644 --- a/scripts/generateTranslations.js +++ b/scripts/generateTranslations.js @@ -9,41 +9,51 @@ import csv from 'csv-parser'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); +// 번역 csv 파일 배열 +const csvs = [ + { locales: 'common.json', translations: 'commonTranslations.csv' }, + { locales: 'mainPage.json', translations: 'mainPageTranslations.csv' }, +]; + // CSV 파일 경로 및 출력 디렉터리 설정 -const csvFilePath = join(__dirname, '..', 'translations', 'translations.csv'); +const csvFilePaths = csvs.map(csv => ({ + locales: csv.locales, + translations: join(__dirname, '..', 'translations', csv.translations), +})); const localesPath = join(__dirname, '..', 'locales'); -// 언어별 번역 데이터를 담을 객체 -const translations = {}; - // CSV 파일을 스트림으로 읽고, 각 행(row)을 처리 -fs.createReadStream(csvFilePath) - .pipe(csv()) - .on('data', row => { - const translationKey = row.key; - for (const lang in row) { - if (lang === 'key') continue; - if (!translations[lang]) { - translations[lang] = {}; +csvFilePaths.forEach(csvFilePath => { + // 언어별 번역 데이터를 담을 객체 + const translations = {}; + fs.createReadStream(csvFilePath.translations) + .pipe(csv()) + .on('data', row => { + const translationKey = row.key; + for (const lang in row) { + if (lang === 'key') continue; + if (!translations[lang]) { + translations[lang] = {}; + } + translations[lang][translationKey] = row[lang]; } - translations[lang][translationKey] = row[lang]; - } - }) - .on('end', () => { - console.log('CSV 파일 읽기 완료!'); + }) + .on('end', () => { + console.log('CSV 파일 읽기 완료!'); - // 언어별로 common.json 파일 생성 - for (const lang of Object.keys(translations)) { - const langDir = join(localesPath, lang); - if (!fs.existsSync(langDir)) { - fs.mkdirSync(langDir, { recursive: true }); + // 언어별로 json 파일 생성 + for (const lang of Object.keys(translations)) { + const langDir = join(localesPath, lang); + if (!fs.existsSync(langDir)) { + fs.mkdirSync(langDir, { recursive: true }); + } + const jsonFilePath = join(langDir, csvFilePath.locales); + fs.writeFileSync( + jsonFilePath, + JSON.stringify(translations[lang], null, 2), + 'utf8', + ); + console.log(`${lang} -> ${jsonFilePath} 생성 완료`); } - const jsonFilePath = join(langDir, 'common.json'); - fs.writeFileSync( - jsonFilePath, - JSON.stringify(translations[lang], null, 2), - 'utf8', - ); - console.log(`${lang} -> ${jsonFilePath} 생성 완료`); - } - }); + }); +}); diff --git a/translations/commonTranslations.csv b/translations/commonTranslations.csv new file mode 100644 index 0000000..ecd8a96 --- /dev/null +++ b/translations/commonTranslations.csv @@ -0,0 +1,8 @@ +key,ko,en +signUp,회원가입,Sign up +login,로그인,Login +searchRecruitment,채용 공고 검색하기,Search for job postings +recruitmentInfo,채용정보,recruitment +companiesInfo,기업정보,Companies +nearBy,주변기업찾기,Surrounding +community,커뮤니티,Community diff --git a/translations/translations.csv b/translations/mainPageTranslations.csv similarity index 60% rename from translations/translations.csv rename to translations/mainPageTranslations.csv index 4e4d170..9a04055 100644 --- a/translations/translations.csv +++ b/translations/mainPageTranslations.csv @@ -1,11 +1,4 @@ key,ko,en -signUp,회원가입,Sign up -login,로그인,Login -searchRecruitment,채용 공고 검색하기,Search for job postings -recruitmentInfo,채용정보,recruitment -companiesInfo,기업정보,Companies -nearBy,주변기업찾기,Surrounding -community,커뮤니티,Community mainBannerTitle1,외국인을 위한,For foreigners mainBannerTitle2,채용 플랫폼,recruitment platform mainBannerSubtitle,한국에서 일자리를 찾고 있는 외국인을 위한 맞춤형 취업 정보와 서비스를 제공합니다,It provides customized employment information and services for foreigners looking for a job in Korea From 8719a4607fbe2d764f4985ce6be25e8d3f83cd00 Mon Sep 17 00:00:00 2001 From: oko_jin Date: Sat, 29 Mar 2025 15:25:20 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20mainPage.json=EC=9D=84=20i18n?= =?UTF-8?q?=EC=97=90=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #25 --- i18n/i18n.ts | 14 ++++++++++++-- locales/en/mainPage.json | 4 +++- locales/ko/mainPage.json | 4 +++- src/components/main/Banner.tsx | 2 +- src/components/main/SearchSection.tsx | 9 +++++---- translations/mainPageTranslations.csv | 4 +++- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/i18n/i18n.ts b/i18n/i18n.ts index 278ba0c..35413a3 100644 --- a/i18n/i18n.ts +++ b/i18n/i18n.ts @@ -2,17 +2,27 @@ import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; import enCommon from '../locales/en/common.json'; +import enMainPage from '../locales/en/mainPage.json'; import koCommon from '../locales/ko/common.json'; +import koMainPage from '../locales/ko/mainPage.json'; const resources = { - en: { common: enCommon }, - ko: { common: koCommon }, + en: { + common: enCommon, + mainPage: enMainPage, + }, + ko: { + common: koCommon, + mainPage: koMainPage, + }, }; i18n.use(initReactI18next).init({ resources, lng: 'ko', fallbackLng: 'en', + ns: ['common', 'mainPage'], + defaultNS: 'common', interpolation: { escapeValue: false, }, diff --git a/locales/en/mainPage.json b/locales/en/mainPage.json index e5ecca3..53acd67 100644 --- a/locales/en/mainPage.json +++ b/locales/en/mainPage.json @@ -2,5 +2,7 @@ "mainBannerTitle1": "For foreigners", "mainBannerTitle2": "recruitment platform", "mainBannerSubtitle": "It provides customized employment information and services for foreigners looking for a job in Korea", - "viewRecruitment": "View Recruitment" + "viewRecruitment": "View Recruitment", + "searchTitle": "Find the job you want", + "searchSubTitle": "You can search for customized recruitment information by keyword, region, occupation, etc." } \ No newline at end of file diff --git a/locales/ko/mainPage.json b/locales/ko/mainPage.json index ab11a38..4941b0a 100644 --- a/locales/ko/mainPage.json +++ b/locales/ko/mainPage.json @@ -2,5 +2,7 @@ "mainBannerTitle1": "외국인을 위한", "mainBannerTitle2": "채용 플랫폼", "mainBannerSubtitle": "한국에서 일자리를 찾고 있는 외국인을 위한 맞춤형 취업 정보와 서비스를 제공합니다", - "viewRecruitment": "채용정보 보기" + "viewRecruitment": "채용정보 보기", + "searchTitle": "원하는 일자리를 찾아보세요", + "searchSubTitle": "키워드, 지역, 직종 등으로 맞춤형 채용정보를 검색할 수 있습니다." } \ No newline at end of file diff --git a/src/components/main/Banner.tsx b/src/components/main/Banner.tsx index c8efb8d..d8c9a6e 100644 --- a/src/components/main/Banner.tsx +++ b/src/components/main/Banner.tsx @@ -4,7 +4,7 @@ import { ChevronRight } from 'lucide-react'; import { useTranslation } from 'react-i18next'; export default function Banner() { - const { t } = useTranslation('common'); + const { t } = useTranslation('mainPage'); return (
diff --git a/src/components/main/SearchSection.tsx b/src/components/main/SearchSection.tsx index 6f8c79d..ba73d2f 100644 --- a/src/components/main/SearchSection.tsx +++ b/src/components/main/SearchSection.tsx @@ -1,16 +1,17 @@ +import { useTranslation } from 'react-i18next'; import styles from './searchSection.module.scss'; import SearchSectionForm from './SearchSectionForm'; export default function SearchSection() { + const { t } = useTranslation('mainPage'); + return (
-

원하는 일자리를 찾아보세요

-

- 키워드, 지역, 직종 등으로 맞춤형 채용정보를 검색할 수 있습니다. -

+

{t('searchTitle')}

+

{t('searchSubTitle')}

diff --git a/translations/mainPageTranslations.csv b/translations/mainPageTranslations.csv index 9a04055..deaf2b2 100644 --- a/translations/mainPageTranslations.csv +++ b/translations/mainPageTranslations.csv @@ -2,4 +2,6 @@ key,ko,en mainBannerTitle1,외국인을 위한,For foreigners mainBannerTitle2,채용 플랫폼,recruitment platform mainBannerSubtitle,한국에서 일자리를 찾고 있는 외국인을 위한 맞춤형 취업 정보와 서비스를 제공합니다,It provides customized employment information and services for foreigners looking for a job in Korea -viewRecruitment,채용정보 보기,View Recruitment \ No newline at end of file +viewRecruitment,채용정보 보기,View Recruitment +searchTitle,원하는 일자리를 찾아보세요,Find the job you want +searchSubTitle,"키워드, 지역, 직종 등으로 맞춤형 채용정보를 검색할 수 있습니다.","You can search for customized recruitment information by keyword, region, occupation, etc." \ No newline at end of file