Skip to content

Commit

Permalink
docs: 문서에 국제화 추가 (#66)
Browse files Browse the repository at this point in the history
* Add i18n

* Add i18n

* Add i18n

* Translate disassembleHangulToGroups

* Make translation of josa better

* Update docs/src/middleware.ts

Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>

* Add translation to feedback & edit link

* Remove examples

* Update docs/src/pages/_meta.ko.json

* Update docs/src/pages/docs/_meta.en.json

* Update docs/src/pages/docs/api/disassembleHangul.en.md

---------

Co-authored-by: Sojin Park <raon0211@X.local>
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
  • Loading branch information
3 people authored Apr 22, 2024
1 parent 28f1499 commit 939d2bd
Show file tree
Hide file tree
Showing 23 changed files with 352 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ const withNextra = require('nextra')({
/** @type {import('next').NextConfig} */
module.exports = withNextra({
reactStrictMode: true,
i18n: {
locales: ['en', 'ko'],
defaultLocale: 'ko'
}
});
1 change: 1 addition & 0 deletions docs/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { locales as middleware } from 'nextra/locales';
13 changes: 13 additions & 0 deletions docs/src/pages/_meta.en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"index": {
"type": "page",
"display": "hidden",
"theme": {
"layout": "full"
}
},
"docs": {
"type": "page",
"title": "Documentation"
}
}
2 changes: 1 addition & 1 deletion docs/src/pages/_meta.json → docs/src/pages/_meta.ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
},
"docs": {
"type": "page",
"title": "문서보기"
"title": "문서"
}
}
10 changes: 10 additions & 0 deletions docs/src/pages/docs/_meta.en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"introduction": "Introduction",
"installation": "Installation",
"api": {
"title": "Usage",
"theme": {
"collapsed": false
}
}
}
File renamed without changes.
23 changes: 23 additions & 0 deletions docs/src/pages/docs/api/chosungIncludes.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: chosungIncludes
---

# chosungIncludes

Performs a search for matches in the initial consonants of a string.

```typescript
function chosungIncludes(
// The string to be checked for matching initial consonants (e.g., '프론트엔드')
x: string,
// Initial consonant string (e.g., 'ㅍㄹㅌㅇㄷ')
y: string
): boolean;
```

```typescript
chosungIncludes('프론트엔드', 'ㅍㄹㅌ'); // true
chosungIncludes('00프론트엔드', 'ㅍㄹㅌ'); // true
chosungIncludes('프론트엔드', 'ㅍㅌ'); // false
chosungIncludes('프론트엔드', '푸롴트'); // false
```
File renamed without changes.
25 changes: 25 additions & 0 deletions docs/src/pages/docs/api/disassembleHangul.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: disassembleHangul
---

# disassembleHangul

Completely separates a Hangul string into its individual characters by initial consonants, medial vowels, and final consonants, creating a single string.

For detailed examples, see below.

```typescript
function disassembleHangul(
// The Korean string to be disassembled
str: string
): string;
```

## Examples

```tsx
disassembleHangul(''); // 'ㄱㅏㅂㅅ'
disassembleHangul('값이 비싸다'); // 'ㄱㅏㅂㅅㅇㅣ ㅂㅣㅆㅏㄷㅏ'
disassembleHangul(''); // 'ㅗㅏ'
disassembleHangul(''); // 'ㄴㅈ'
```
26 changes: 26 additions & 0 deletions docs/src/pages/docs/api/disassembleHangulToGroups.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: disassembleHangulToGroups
---

# disassembleHangulToGroups

Completely separate a Hangul string into individual characters based on the initial consonant, medial vowel, and final consonant.

Complex consonants like `` are split into `['ㄴ', 'ㅈ']`, and complex vowels like `` are split into `['ㅗ', 'ㅏ']`.

For detailed examples, please refer to the section below.

```typescript
function disassembleHangulToGroups(
// The Korean string to be disassembled
str: string
): string[][];
```

## Examples

```typescript
disassembleHangulToGroups(''); // [['ㄱ', 'ㅏ', 'ㅂ', 'ㅅ']]
disassembleHangulToGroups(''); // [['ㅗ', 'ㅏ']]
disassembleHangulToGroups(''); // [['ㄴ', 'ㅈ']]
```
28 changes: 28 additions & 0 deletions docs/src/pages/docs/api/hangulIncludes.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: hangulIncludes
---

# hangulIncludes

Checks if a Hangul string contains another Hangul string.

For example, `사과` contains ``, and `값이 비싸다` contains `` or ``.

```typescript
function hangulIncludes(
// The string to be checked for containing the second argument y
x: string,
// The string to be checked for inclusion in the first argument x
y: string
): boolean;
```

## Examples

```typescript
hangulIncludes('사과', ''); // true
hangulIncludes('사과', ''); // true
hangulIncludes('사과', ''); // true
hangulIncludes('사과', ''); // false
hangulIncludes('사과', '사과'); // true
```
File renamed without changes.
39 changes: 39 additions & 0 deletions docs/src/pages/docs/api/josa.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: josa
---

# josa

Add a particle to a Hangul string. It can support particles like '이/가', '을/를', '은/는', '으로/로', '와/과', '이나/나', '이란/란', '아/야', '이랑/랑', '이에요/예요', '으로서/로서', '으로써/로써', '으로부터/로부터'.

```typescript
function josa(
// The Hangul string to add a particle
word: string,
// The particle to attach
josa:
| '이/가'
| '을/를'
| '은/는'
| '으로/로'
| '와/과'
| '이나/나'
| '이에/에'
| '이란/란'
| '아/야'
| '이랑/랑'
| '이에요/예요'
| '으로서/로서'
| '으로써/로써'
| '으로부터/로부터'
): string;
```

## Examples

```typescript
josa('샴푸', '이/가'); // '샴푸가'
josa('칫솔', '이/가'); // '칫솔이'
josa('바깥', '으로/로'); // '바깥으로'
josa('내부', '으로/로'); // '내부로'
```
File renamed without changes.
5 changes: 5 additions & 0 deletions docs/src/pages/docs/installation.en.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Installing es-hangul

```shell npm2yarn
npm install es-hangul
```
File renamed without changes.
81 changes: 81 additions & 0 deletions docs/src/pages/docs/introduction.en.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { Steps, Callout } from 'nextra/components';

# Introduction to es-hangul

[![npm version](https://img.shields.io/npm/v/es-hangul?color=000&labelColor=000&logo=npm&label=)](https://www.npmjs.com/package/es-hangul) [![npm](https://img.shields.io/npm/dm/es-hangul?color=000&labelColor=000)](https://www.npmjs.com/package/es-hangul)

When developing products that handle Hangul, tasks such as initial consonant search and accurate particle attachment often need to be performed. In addition, there are cases where you need to separate or combine Hangul elements like initial consonants, vowels, and final consonants. es-hangul helps to easily and quickly implement these frequently occurring Hangul-related functions in business.

<br />

## Key features

<Steps>

### Lightweight and Tree-shakable

By using ECMAScript Modules, you can include only the functions you use in your application. For example, if you use the `josa` function, only the related logic is included in the application. Additionally, by providing the minimum necessary code for handling Hangul, you can reduce the size of the JavaScript downloaded by users. (The entire library is about 1KB when compressed with Gzip.) [![es-hangul's badge](https://deno.bundlejs.com/?q=es-hangul&badge=detailed)](https://bundlejs.com/?q=es-hangul)

### Battle-tested

We strive to test all features with the goal of achieving 100% coverage.

[![codecov](https://codecov.io/gh/toss/es-hangul/branch/main/graph/badge.svg?token=토큰추가가필요합니다)](https://codecov.io/gh/toss/es-hangul)

### TypeScript Support

Our library provides strong typing, allowing for easy detection of type errors during the development phase.

### Full Support for Hangul-related Features

Our library provides a [modern API](./api/chosungIncludes) that can be conveniently used in various applications.

#### First Consonant Search ([chosungIncludes](./api/chosungIncludes))

It checks whether an initial consonant is included in a specific word. For example, you can easily find out if the word '라면' (ramyeon) contains the initial consonants 'ㄹㅁ'.

```tsx /chosungIncludes/
import { chosungIncludes } from 'es-hangul';

const searchWord = '라면';
const userInput = 'ㄹㅁ';

const result = chosungIncludes(searchWord, userInput);
console.log(result); // true
```

#### Disassembling Hangul Characters ([disassembleHangul](./api/disassembleHangul))

You can decompose a given Hangul string into initial consonants, vowels, and final consonants, and return it in array form to allow for more detailed analysis or modification of the string.

```tsx /disassembleHangul/
import { disassembleHangul } from 'es-hangul';

const word = '안녕하세요';
const disassembled = disassembleHangul(word);
console.log(disassembled); // 'ㅇㅏㄴㄴㅕㅇㅎㅏㅅㅔㅇㅛ'
```

#### Handling Particles ([josa](./api/josa))

It automatically selects the appropriate particle based on whether the last letter of a word has a final consonant or not.

```tsx /josa/
import { josa } from 'es-hangul';

const word1 = '사과';
const sentence1 = josa(word1, '을/를') + ' 먹었습니다.';
console.log(sentence1); // '사과를 먹었습니다.'

const word2 = '바나나';
const sentence2 = josa(word2, '이/가') + ' 맛있습니다.';
console.log(sentence2); // '바나나가 맛있습니다.'
```

<Callout type="info">

If you have a good idea for handling Hangul well, please let us know. [Suggest a feature via GitHub Issue](https://github.com/toss/es-hangul/issues/new?assignees=&labels=feature&projects=&template=feature_request.yml&title=%5BFeature%5D%3A)

</Callout>

</Steps>
File renamed without changes.
59 changes: 59 additions & 0 deletions docs/src/pages/index.en.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: es-hangul
---

import Link from 'next/link';
import { Callout, useTheme, Steps } from 'nextra-theme-docs';

<style jsx global>{`
body {
background-image: radial-gradient(#ddd 1px, transparent 0), radial-gradient(#ddd 1px, transparent 0);
background-position:
0 0,
20px 20px;
background-size: 40px 40px;
word-break: keep-all;
}
.dark body {
background-image: radial-gradient(#333 1px, transparent 0), radial-gradient(#333 1px, transparent 0);
}
`}</style>

<img src="/og.png" style={{ width: '100%', maxWidth: 400, margin: '32px auto' }} />

<div className="flex flex-col items-center justify-center gap-8 pt-6 text-center">
<div className="flex flex-col items-center gap-4">
<div className="relative text-3xl">
<h3 className="">A modern JavaScript Hangul library</h3>
</div>
<Callout className="w-full">
es-hangul is a small JavaScript library that helps you conveniently handle Hangul. It provides a convenient and clean API for actions such as searching for initial consonants and attaching particles.
</Callout>
</div>
</div>

```tsx
import { chosungIncludes } from 'es-hangul';

const searchWord = '라면';
const userInput = 'ㄹㅁ';

const result = chosungIncludes(searchWord, userInput);
console.log(result); // true
```

```tsx
import { josa } from 'es-hangul';

const word1 = '사과';
const sentence1 = josa(word1, '을/를') + ' 먹었습니다.';
console.log(sentence1); // '사과를 먹었습니다.'

const word2 = '바나나';
const sentence2 = josa(word2, '이/가') + ' 맛있습니다.';
console.log(sentence2); // '바나나가 맛있습니다.'
```

<div className="mt-16 mb-20 text-center">
[Get Started](/docs/introduction) · [API](/docs/api/josa) · [GitHub Repository](https://github.com/toss/es-hangul)
</div>
File renamed without changes.
Loading

0 comments on commit 939d2bd

Please sign in to comment.