diff --git a/packages/viewer/src/header.ts b/packages/viewer/src/header.ts index 546c0dd..d1d341f 100644 --- a/packages/viewer/src/header.ts +++ b/packages/viewer/src/header.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import loadString from './string' import printFrame from './utils/print' class Header { @@ -159,7 +160,7 @@ class Header { title.appendChild(link) const description = document.createElement('p') - description.textContent = '본 제품은 한글과컴퓨터의 한/글 문서 파일(.hwp) 공개 문서를 참고하여 개발하였습니다.' + description.textContent = loadString('about') const copyright = document.createElement('p') copyright.textContent = 'Copyright 2020 Han Lee and other contributors.' @@ -197,7 +198,7 @@ class Header { this.pageNumber.textContent = '1' const totalPages = document.createElement('span') - totalPages.textContent = `/${this.pages.length}쪽` + totalPages.textContent = `/${this.pages.length}${loadString('page')}` this.container.appendChild(this.pageNumber) this.container.appendChild(totalPages) diff --git a/packages/viewer/src/string/index.ts b/packages/viewer/src/string/index.ts new file mode 100644 index 0000000..8342d04 --- /dev/null +++ b/packages/viewer/src/string/index.ts @@ -0,0 +1,16 @@ +const supportedLanguages = ['ko', 'en-US'] +const defaultLanguage = 'en-US' + +import {default as Korean} from "./translation/ko.json" +import {default as English} from "./translation/english.json" + +const strings = { + "ko": Korean, + "en-US": English +} as any + +export default function loadString(key: string) { + let language = window.navigator.language + if (!supportedLanguages.includes(language)) language = defaultLanguage + return strings[language][key] +} diff --git a/packages/viewer/src/string/translation/english.json b/packages/viewer/src/string/translation/english.json new file mode 100644 index 0000000..feccc13 --- /dev/null +++ b/packages/viewer/src/string/translation/english.json @@ -0,0 +1,4 @@ +{ + "page": " page", + "about": "This product is developed by referring to the HANCOM Group's Hangul Document File (.hwp) public documentation." +} diff --git a/packages/viewer/src/string/translation/ko.json b/packages/viewer/src/string/translation/ko.json new file mode 100644 index 0000000..fa6bc81 --- /dev/null +++ b/packages/viewer/src/string/translation/ko.json @@ -0,0 +1,4 @@ +{ + "page": "쪽", + "about": "본 제품은 한글과컴퓨터의 한/글 문서 파일(.hwp) 공개 문서를 참고하여 개발하였습니다." +} diff --git a/tsconfig.base.json b/tsconfig.base.json index dc6b63b..2ae7582 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -4,6 +4,7 @@ "declaration": true, "emitDeclarationOnly": true, "declarationDir": "./build", + "resolveJsonModule": true, "lib": [ "es2017", "dom",