Skip to content

Commit

Permalink
Merge pull request #2 from kabrunko-dev/feat/translate-details
Browse files Browse the repository at this point in the history
feat: enhance readme i18n details collapsible
  • Loading branch information
kabrunko-dev authored Jan 15, 2024
2 parents 740ec1b + ffbf7dc commit c3d3621
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions scripts/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"badge.share-your-solutions": "Share your Solutions",
"badge.take-the-challenge": "Take the Challenge",
"badge.preview-playground": "Preview in Playground",
"details.by-tags": "By Tags",
"details.by-plain-text": "By Plain Text",
"difficulty.easy": "easy",
"difficulty.extreme": "extreme",
"difficulty.hard": "hard",
Expand Down
2 changes: 2 additions & 0 deletions scripts/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"badge.preview-playground": "Playgroundでプレビュー",
"badge.share-your-solutions": "解答を共有",
"badge.take-the-challenge": "挑戦する",
"details.by-tags": "タグ別",
"details.by-plain-text": "プレーンテキストによる",
"difficulty.easy": "初級",
"difficulty.extreme": "最上級",
"difficulty.hard": "上級",
Expand Down
2 changes: 2 additions & 0 deletions scripts/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"badge.share-your-solutions": "정답 공유하기",
"badge.take-the-challenge": "도전하기",
"badge.preview-playground": "Playground에서 미리보기",
"details.by-tags": "태그별",
"details.by-plain-text": "일반 텍스트로",
"difficulty.easy": "쉬움",
"difficulty.extreme": "매우 어려움",
"difficulty.hard": "어려움",
Expand Down
2 changes: 2 additions & 0 deletions scripts/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"badge.share-your-solutions": "Compartilhar suas Soluções",
"badge.take-the-challenge": "Fazer o Desafio",
"badge.preview-playground": "Pré-visualizar no Playground",
"details.by-tags": "Por Tags",
"details.by-plain-text": "Por Texto Simples",
"difficulty.easy": "fácil",
"difficulty.extreme": "extremo",
"difficulty.hard": "difícil",
Expand Down
2 changes: 2 additions & 0 deletions scripts/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"badge.share-your-solutions": "分享你的解答",
"badge.take-the-challenge": "接受挑战",
"badge.preview-playground": "在 Playground 中预览",
"details.by-tags": "按标签",
"details.by-plain-text": "通过纯文本",
"difficulty.easy": "简单",
"difficulty.extreme": "地狱",
"difficulty.hard": "困难",
Expand Down
8 changes: 6 additions & 2 deletions scripts/readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ function toDifficultyPlainText(difficulty: string, locale: SupportedLocale, coun
return `${t(locale, `difficulty.${difficulty}`)} (${count.toString()})`
}

function toDetailsInnerText(text: string, locale: SupportedLocale) {
return `${t(locale, `details.${text}`)}`
}

function quizToBadge(quiz: Quiz, locale: string, absolute = false, badge = true) {
const fn = badge ? toBadgeLink : toPlanTextLink
return fn(
Expand Down Expand Up @@ -162,7 +166,7 @@ async function updateIndexREADME(quizes: Quiz[]) {
}

// by tags
challengesREADME += '<br><details><summary>By Tags</summary><br><table><tbody>'
challengesREADME += `<br><details><summary>${toDetailsInnerText('by-tags', locale)}</summary><br><table><tbody>`
const tags = getAllTags(quizes, locale)
for (const tag of tags) {
challengesREADME += `<tr><td>${toBadge('', `#${tag}`, '999')}</td><td>`
Expand All @@ -177,7 +181,7 @@ async function updateIndexREADME(quizes: Quiz[]) {

// by plain text
prev = ''
challengesREADME += '<br><details><summary>By Plain Text</summary><br>'
challengesREADME += `<br><details><summary>${toDetailsInnerText('by-plain-text', locale)}</summary><br>`
for (const quiz of quizesByDifficulty) {
if (prev !== quiz.difficulty)
challengesREADME += `${prev ? '</ul>' : ''}<h3>${toDifficultyPlainText(quiz.difficulty, locale, quizesByDifficulty.filter(q => q.difficulty === quiz.difficulty).length)}</h3><ul>`
Expand Down

0 comments on commit c3d3621

Please sign in to comment.