Skip to content

Commit

Permalink
파싱 무시 영역 추가 및 Readme 갱신
Browse files Browse the repository at this point in the history
  • Loading branch information
killkimno committed Nov 13, 2022
1 parent a797a2f commit 6c5e532
Show file tree
Hide file tree
Showing 9 changed files with 374 additions and 20 deletions.
Binary file not shown.
Binary file not shown.
78 changes: 68 additions & 10 deletions CSharp-Multilingual-Markdown-Generator/MarkDownParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,41 @@ public enum LanguageType
}

private const string KeyLanguageStart = "<!--";
private const string KeyEn = "<!--[en-us]-->";
private const string KeyKo = "<!--[ko-kr]-->";
private const string KeyJp = "<!--[ja-jp]-->";
private const string KeyFr = "<!--[fr-fr]-->";
private const string KeyEn = "<!--[en]-->";
private const string KeyKr = "<!--[kr]-->";
private const string KeyJp = "<!--[ja]-->";
private const string KeyFr = "<!--[fr]-->";

private const string KeyEnFull = "<!--[en-us]-->";
private const string KeyKrFull = "<!--[ko-kr]-->";
private const string KeyJpFull = "<!--[ja-jp]-->";
private const string KeyFrFull = "<!--[fr-fr]-->";

private const string KeyCommon = "<!--[common]-->";
private const string KeyIgonre = "<!--[ignore]-->";
private const string KeyLink = "<!--[document_link]-->";

private const string KeyIgonoreParse = "```";

private Dictionary<LanguageType, bool> _usingLanguage = new Dictionary<LanguageType, bool>();
private Dictionary<LanguageType, StringBuilder> _dataDic = new Dictionary<LanguageType, StringBuilder>();
private Dictionary<LanguageType, LanguageInformation> _infoDic = new Dictionary<LanguageType, LanguageInformation>();
private string _baseFileName;
private bool _igonoreParse;



private void Init()
{
_igonoreParse = false;
_infoDic.Clear();
_usingLanguage.Clear();
_dataDic.Clear();

_infoDic.Add(LanguageType.Kr, new LanguageInformation(LanguageType.Kr, "ko-KR", "한국어"));
_infoDic.Add(LanguageType.En, new LanguageInformation(LanguageType.En, "en-US", "English"));
_infoDic.Add(LanguageType.Jp, new LanguageInformation(LanguageType.Jp, "ja-JP", "日本語"));
_infoDic.Add(LanguageType.Fr, new LanguageInformation(LanguageType.Fr, "fr-FR", "Français"));
_infoDic.Add(LanguageType.Kr, new LanguageInformation(LanguageType.Kr, "kr", "한국어"));
_infoDic.Add(LanguageType.En, new LanguageInformation(LanguageType.En, "en", "English"));
_infoDic.Add(LanguageType.Jp, new LanguageInformation(LanguageType.Jp, "ja", "日本語"));
_infoDic.Add(LanguageType.Fr, new LanguageInformation(LanguageType.Fr, "fr", "Français"));
}


Expand Down Expand Up @@ -114,6 +126,24 @@ public void GenerateDocument(string filePath, string baseFileName, LanguageType

private CommandType ParaseCommand(string line)
{
if(line == KeyIgonoreParse)
{
if(!_igonoreParse)
{
_igonoreParse = true;
return CommandType.None;
}
else
{
_igonoreParse = false;
}
}

if(_igonoreParse)
{
return CommandType.None;
}

if (line == KeyIgonre)
{
return CommandType.Igonore;
Expand All @@ -137,15 +167,19 @@ private LanguageType ParseLanguage(string line)
switch (line)
{
case KeyEn:
case KeyEnFull:
return LanguageType.En;

case KeyKo:
case KeyKr:
case KeyKrFull:
return LanguageType.Kr;

case KeyJp:
case KeyJpFull:
return LanguageType.Jp;

case KeyFr:
case KeyFrFull:
return LanguageType.Fr;

case KeyCommon:
Expand All @@ -163,25 +197,49 @@ private void InitializeLanguage(string[] lines)
{
string line = readLine.Replace(" ", "").ToLower();

if (line == KeyIgonoreParse)
{
if (!_igonoreParse)
{
_igonoreParse = true;
continue;
}
else
{
_igonoreParse = false;
}
}

if(_igonoreParse)
{
continue;
}

switch (line)
{
case KeyEn:
case KeyEnFull:
_usingLanguage[LanguageType.En] = true;
break;

case KeyKo:
case KeyKr:
case KeyKrFull:
_usingLanguage[LanguageType.Kr] = true;
break;

case KeyJp:
case KeyJpFull:
_usingLanguage[LanguageType.Jp] = true;
break;

case KeyFr:
case KeyFrFull:
_usingLanguage[LanguageType.Fr] = true;
break;
}
}

_igonoreParse = false;
}

private void ParseLines(string[] lines)
Expand Down
152 changes: 152 additions & 0 deletions README.base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# CSharp-Multilingual-Markdown-Generator

<!--[document_link]-->
<!--[kr]-->
다국어 마크다운 문서 생성기

이 프로젝트는 ryul1206님의 multilingual-markdown 프로젝트를 기반으로 만들어 졌습니다.
<!--[en]-->
Multilingual Markdown Generator

This project is based on ryul1206's multilingual-markdown project.
<!--[common]-->

[Link : https://github.com/ryul1206/multilingual-markdown ](https://github.com/ryul1206/multilingual-markdown)

<!--[kr]-->
## 개요
코드 키워드를 이용해 각 언어별 문서를 생성해줍니다.
<!--[en]-->
## Overview
It creates documents for each language using code keywords.

<!--[kr]-->
## 사용법
<!--[en]-->
## How to Use
<!--[kr]-->
### 파일 규칙
<!--[en]-->
### File Rule
<!--[kr]-->
{FileName}.base.md 으로 되어 있어야 합니다. 예시는 [example.base.md](example/example.base.md)을 보시면 됩니다

ex : Readme.base.md
<!--[en]-->
It should be {FileName}.base.md . For an example, see this documnet [example.base.md](example/example.base.md)

ex : Readme.base.md

<!--[kr]-->
### 문서 생성
<!--[en]-->
### Generate Documnet
<!--[kr]-->
문서 생성 / Generate 버튼을 이용해 파일을 선택후 만듭니다
<!--[en]-->
Use '문서 생성 / Generate' button to select a file and create it

<!--[kr]-->
### 주 언어 설정
<!--[en]-->
### Select Main Language
<!--[kr]-->
주 언어 / Main Language 의 라디오 버튼을 이용해 주 언어를 설정합니다.
주 언어로 선택된 언어는 파일 이름에서 .base. 가 제거되어서 나옵니다

(ex :Readme.base.md -> Readme.md)
<!--[en]-->
Use '주 언어 / Main Language' radio button to set the primary language.
The language selected as the primary language is the .base. is removed and comes out

(ex :Readme.base.md -> Readme.md)


<!--[kr]-->
## 코드 키워드
<!--[en]-->
## Code Keyword
<!--[kr]-->
**언어 키워드**

<!--[en]-->
**Language Keyword**

<!--[kr]-->
언어별 텍스트 영역을 구분하는 키워드입니다.
언어 키워드를 인식한 후 다음 언어 키워드나 공통 영역 키워드를 만날때가지 해당 언어로 처리됩니다.

아래는 현재 지원하는 언어입니다
<!--[en]-->
A keyword that separates language-specific text areas.
After recognizing a language keyword, it is processed in that language until the next language keyword or common area keyword is encountered.

currently supported language list
<!--[common]-->
```
<!-- [en] -->
<!-- [kr] -->
<!-- [fr] -->
<!-- [jp] -->
```

<!--[kr]-->
**공통 영역**

<!--[en]-->
**Common Area**

<!--[kr]-->
모든 언어에 공통으로 들어갈 텍스트 영역을 구분하는 키워드입니다.
<!--[en]-->
A keyword that delimits a text area common to all languages.

<!-- [common] -->
```
<!-- [common] -->
```


<!--[kr]-->
**무시 영역**

<!--[en]-->
**Igonore Area**

<!--[kr]-->
주석용으로 쓰는 영역입니다. 이 영역에 지정된 텍스트는 파일에 포함되지 않습니다
<!--[en]-->
This area is used for comments. Text specified in this area will not be included in the file

<!-- [common] -->
```
<!-- [ignore] -->
```


<!--[kr]-->
**언어 링크 키워드**

<!--[en]-->
**Language Link**


<!--[kr]-->
이 키워드가 있는 곳는 언어별 문서 링크 텍스트로 대체됩니다. 문서에 포함된 언어를 자동으로 링크해 줍니다
<!--[en]-->
Wherever this keyword appears, it will be replaced with the language-specific document link text.
Automatically links to languages embedded in documents

<!-- [common] -->
```
<!-- [document_link] -->
```









80 changes: 80 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# CSharp-Multilingual-Markdown-Generator

🌏[한국어](README.kr.md) | [English](README.en.md)


Multilingual Markdown Generator

This project is based on ryul1206's multilingual-markdown project.

[Link : https://github.com/ryul1206/multilingual-markdown ](https://github.com/ryul1206/multilingual-markdown)

## Overview
It creates documents for each language using code keywords.

## How to Use
### File Rule
It should be {FileName}.base.md . For an example, see this documnet [example.base.md](example/example.base.md)

ex : Readme.base.md

### Generate Documnet
Use '문서 생성 / Generate' button to select a file and create it

### Select Main Language
Use '주 언어 / Main Language' radio button to set the primary language.
The language selected as the primary language is the .base. is removed and comes out

(ex :Readme.base.md -> Readme.md)


## Code Keyword
**Language Keyword**

A keyword that separates language-specific text areas.
After recognizing a language keyword, it is processed in that language until the next language keyword or common area keyword is encountered.

currently supported language list
```
<!-- [en] -->
<!-- [kr] -->
<!-- [fr] -->
<!-- [jp] -->
```

**Common Area**

A keyword that delimits a text area common to all languages.

```
<!-- [common] -->
```


**Igonore Area**

This area is used for comments. Text specified in this area will not be included in the file

```
<!-- [ignore] -->
```


**Language Link**


Wherever this keyword appears, it will be replaced with the language-specific document link text.
Automatically links to languages embedded in documents

```
<!-- [document_link] -->
```









Loading

0 comments on commit 6c5e532

Please sign in to comment.