Skip to content

Commit d398242

Browse files
authored
Update README.md and Add README-ja.md (#16)
1 parent 0fcea98 commit d398242

File tree

2 files changed

+82
-9
lines changed

2 files changed

+82
-9
lines changed

README-ja.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# react-segmenter
2+
3+
[![NPM](https://img.shields.io/npm/v/react-segmenter.svg)](https://www.npmjs.com/package/react-segmenter)
4+
5+
[README.md - English)](/README.md)
6+
7+
---
8+
9+
**react-segmenter** は、ブラウザ上で和文の改行をより読みやすくするための React コンポーネントを提供するライブラリです。ECMA402 の [`Intl.Segmenter`](https://github.com/tc39/proposal-intl-segmenter) を使用して和文を適切に分かち書きし、ブラウザに改行可能箇所を教えることで快適な読みやすさを実現します。特に、モバイル端末のような画面幅が狭い場合やレスポンシブUIを作る上で有効です。
10+
11+
12+
## Installation
13+
14+
```bash
15+
npm install react-segmenter
16+
17+
# or
18+
19+
yarn add react-segmenter
20+
```
21+
22+
23+
## Usage
24+
25+
```tsx
26+
import React from 'react';
27+
import { TextSegmenter } from 'react-segmenter';
28+
29+
const App = () => {
30+
return (
31+
<TextSegmenter>ここに改行されるべき日本語の文章を入れてください。</TextSegmenter>
32+
);
33+
};
34+
```
35+
36+
37+
## Notes
38+
39+
- このライブラリは、主に日本語の改行位置制御を目的としています。英語の場合は、CSS を変更し、ブラウザに任せることを推奨します。
40+
- Intl.Segmenter の実装は、処理系によって異なる可能性があるため、異なる分割結果が得られることがあります。この点に注意して使用してください。
41+
- ブラウザによっては、Intl.Segmenter がサポートされていない場合があります。その場合は、当ライブラリを使用する際に問題が発生する可能性があるため注意が必要です。
42+
43+
44+
## License
45+
46+
MIT © [NotFounds (Iori IKEDA)](https://github.com/NotFounds)
47+
48+
49+
## References
50+
51+
[Intl.Segmenter で和文の改行をいい感じにしてみる](https://zenn.dev/notfounds/articles/58c465d4029dc1)

README.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
11
# react-segmenter
22

3-
> A React component that utilizes Intl.Segmenter to control line breaks in Japanese text.
3+
[![NPM](https://img.shields.io/npm/v/react-segmenter.svg)](https://www.npmjs.com/package/react-segmenter)
44

5-
[![NPM](https://img.shields.io/npm/v/react-segmenter.svg)](https://www.npmjs.com/package/react-segmenter) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
5+
[README-ja.md - 日本語)](/README-ja.md)
66

7-
## Install
7+
---
8+
9+
**react-segmenter** is a library that provides a React component for improving the line breaks of Japanese text in a browser. By using ECMA402's [`Intl.Segmenter`](https://github.com/tc39/proposal-intl-segmenter), it properly segments Japanese text and informs the browser of possible line break points, achieving comfortable readability. It is particularly effective for cases with narrow screen widths, such as mobile devices, and when creating responsive UIs.
10+
11+
12+
## Installation
813

914
```bash
15+
npm install react-segmenter
16+
17+
# or
18+
1019
yarn add react-segmenter
1120
```
1221

22+
1323
## Usage
1424

1525
```tsx
16-
import React from 'react'
17-
18-
import { TextSegmenter } from 'react-segmenter'
26+
import React from 'react';
27+
import { TextSegmenter } from 'react-segmenter';
1928

20-
const App: React.FC = () => {
29+
const App = () => {
2130
return (
22-
<TextSegmenter>Hello World!</TextSegmenter>
31+
<TextSegmenter>Insert Japanese text that should be broken into lines here.</TextSegmenter>
2332
);
2433
};
2534
```
2635

36+
37+
## Notes
38+
39+
- This library is primarily intended for controlling line breaks in Japanese text. For English text, it is recommended to change the CSS and leave it to the browser.
40+
- Since the implementation of Intl.Segmenter may vary depending on the processing system, different segmentation results may be obtained. Be aware of this when using the library.
41+
- Some browsers may not support Intl.Segmenter. In such cases, be cautious as there may be issues when using this library.
42+
43+
2744
## License
2845

29-
MIT © [NotFounds](https://github.com/NotFounds)
46+
MIT © [NotFounds (Iori IKEDA)](https://github.com/NotFounds)
47+
48+
49+
## References
50+
51+
[Intl.Segmenter で和文の改行をいい感じにしてみる(Japanese)](https://zenn.dev/notfounds/articles/58c465d4029dc1)

0 commit comments

Comments
 (0)