Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelly-wu committed Jun 7, 2023
1 parent 08b7c17 commit 493e6a5
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ t(`hello world`)
/** Support Variable Interpolation */

t('hello {0}', 'developer friends'),
t('This is {0}, welcome to {1}. If you think {2}, please give {3} your support', ' `i18n-pro` ', 'use', `it's good`, ' ⭐️ ')
t('This is {0}, welcome to {1}. If you think {2}, please give {3} your support', ' `i18n-pro` ', 'use', `it's helpful for you`, ' ⭐️ ')


/** Interpolation Variable type tag need to be used with corresponding formatting callbacks */
Expand Down
2 changes: 1 addition & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ t(`hello world`)
/** 支持变量插值 */

t('hello {0}', '开发者朋友们'),
t('这是{0},欢迎{1},如果你觉得{2},请给予{3}支持', ' `i18n-pro` ', '使用', `不错`, ' ⭐️ ')
t('这是{0},欢迎{1},如果你觉得{2},请给予{3}支持', ' `i18n-pro` ', '使用', `对你有帮助`, ' ⭐️ ')


/** 插值变量类型标记,需配合对应的格式化回调 */
Expand Down
8 changes: 6 additions & 2 deletions docs/dist/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

# Changelog


English | [简体中文](https://github.com/i18n-pro/core/blob/v2.0.0-alpha.8/docs/dist/CHANGELOG_zh-CN.md)


<details >
<summary>Table of Contents</summary>

&emsp;&emsp;[[2.0.0] - 2023-0x-xx](#200---2023-0x-xx)<br/>
&emsp;&emsp;[[2.0.0] - 2023-06-07](#200---2023-06-07)<br/>
&emsp;&emsp;&emsp;&emsp;[Command Line Tool](#200-command-line-tool)<br/>
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;[Changed](#200-command-line-tool-changed)<br/>
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;[Added](#200-command-line-tool-added)<br/>
Expand Down Expand Up @@ -61,7 +65,7 @@

</details>

## [2.0.0] - 2023-0x-xx
## [2.0.0] - 2023-06-07

<h3 id="200-command-line-tool">Command Line Tool</h3>

Expand Down
8 changes: 6 additions & 2 deletions docs/dist/CHANGELOG_zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

# 更新日志


[English](https://github.com/i18n-pro/core/blob/v2.0.0-alpha.8/docs/dist/CHANGELOG.md) | 简体中文


<details >
<summary>目录</summary>

&emsp;&emsp;[[2.0.0] - 2023-0x-xx](#200---2023-0x-xx)<br/>
&emsp;&emsp;[[2.0.0] - 2023-06-07](#200---2023-06-07)<br/>
&emsp;&emsp;&emsp;&emsp;[命令行工具](#200-命令行工具)<br/>
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;[Changed](#200-命令行工具-changed)<br/>
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;[Added](#200-命令行工具-added)<br/>
Expand Down Expand Up @@ -61,7 +65,7 @@

</details>

## [2.0.0] - 2023-0x-xx
## [2.0.0] - 2023-06-07

<h3 id="200-命令行工具">命令行工具</h3>

Expand Down
2 changes: 1 addition & 1 deletion docs/dist/CONTRIBUTION_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Contribution Guidelines
First of all, a warm welcome to those who want to participate in this project 👏🏻👏🏻👏🏻

But sorry, the current document is still being planned and improved... (maybe you can start from this document)
But sorry, the current document is still being planned and improved... (Maybe you can start from this document, writing documents is not an easy task 😂)

Finally, please don't lose your enthusiasm, please continue to pay attention!
2 changes: 1 addition & 1 deletion docs/dist/CONTRIBUTION_GUIDELINES_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# 贡献指南
首先,对各位想要参与到本项目来表示热烈欢迎👏🏻👏🏻👏🏻

但是抱歉的是,当前文档还在规划完善中...(也许可以从该文档开始
但是抱歉的是,当前文档还在规划完善中...(也许你可以从该文档开始,写文档绝不是一件容易的事😂

最后,请不要丢失你的热情,请持续保持关注!
4 changes: 3 additions & 1 deletion docs/src/changelog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getTranslationText,
getVariableInterpolation,
initI18n,
renderLanguage,
} from '../utils'
import Template from './ChangeLog'

Expand Down Expand Up @@ -294,7 +295,7 @@ function V_2_0_0() {
return (
<Template
version="2.0.0"
date="2023-0x-xx"
date="2023-06-07"
commandLine={{
changed: [
'U',
Expand Down Expand Up @@ -416,6 +417,7 @@ export default function ChangeLog(props) {
return (
<>
<H1 skip>{tr('更新日志')}</H1>
{renderLanguage('CHANGELOG')}
<TableOfContents text={tr('目录')} open={false} />
<V_2_0_0 />
<V_1_3_2 />
Expand Down
4 changes: 3 additions & 1 deletion docs/src/contribution-guidelines/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export default function OutputLog(props) {
{tr('首先,对各位想要参与到本项目来表示热烈欢迎{0}', '👏🏻👏🏻👏🏻')}
<Break />
<Break />
{tr('但是抱歉的是,当前文档还在规划完善中...(也许可以从该文档开始)')}
{tr(
'但是抱歉的是,当前文档还在规划完善中...(也许你可以从该文档开始,写文档绝不是一件容易的事😂)',
)}
<Break />
<Break />
{tr('最后,请不要丢失你的热情,请持续保持关注!')}
Expand Down
6 changes: 3 additions & 3 deletions docs/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@
"开发者朋友们": "developer friends",
"这是{0},欢迎{1},如果你觉得{2},请给予{3}支持": "This is {0}, welcome to {1}. If you think {2}, please give {3} your support",
"使用": "use",
"不错": "it's good",
"hello {0}world{1}": "hello {0}world{1}",
"格式": "Format",
"例如": "For example",
Expand Down Expand Up @@ -386,6 +385,7 @@
"不能正常提取{0}": "Can't extract {0}",
"贡献指南": "Contribution Guidelines",
"首先,对各位想要参与到本项目来表示热烈欢迎{0}": "First of all, a warm welcome to those who want to participate in this project {0}",
"但是抱歉的是,当前文档还在规划完善中...(也许可以从该文档开始)": "But sorry, the current document is still being planned and improved... (maybe you can start from this document)",
"最后,请不要丢失你的热情,请持续保持关注!": "Finally, please don't lose your enthusiasm, please continue to pay attention!"
"最后,请不要丢失你的热情,请持续保持关注!": "Finally, please don't lose your enthusiasm, please continue to pay attention!",
"但是抱歉的是,当前文档还在规划完善中...(也许你可以从该文档开始,写文档绝不是一件容易的事😂)": "But sorry, the current document is still being planned and improved... (Maybe you can start from this document, writing documents is not an easy task 😂)",
"对你有帮助": "it's helpful for you"
}
4 changes: 3 additions & 1 deletion docs/src/readme/Principle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ t(\`hello world\`)
t('hello {0}', '${tr('开发者朋友们')}'),
t('${tr(
'这是{0},欢迎{1},如果你觉得{2},请给予{3}支持',
)}', ' \`i18n-pro\` ', '${tr('使用')}', \`${tr('不错')}\`, ' ⭐️ ')
)}', ' \`i18n-pro\` ', '${tr('使用')}', \`${tr(
'对你有帮助',
)}\`, ' ⭐️ ')
/** ${tr(
Expand Down
37 changes: 3 additions & 34 deletions docs/src/readme/Top.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
import { Image, Link, Break } from 'jsx-to-md'
import { linkObj, imageObj, langs } from '../constants'
import { homepage, version } from '../../../package.json'

const separator = ' | '

function renderLanguage() {
const res = langs.reduce((res, item, index) => {
const { code, locale, name } = item
const EN_URL = `${homepage}/tree/v${version}#readme`
const OTHER_URL = `${homepage}/blob/v${version}/README_${locale}.md`

if (global.docLocale == code) {
res.push(name)
} else {
res.push(<Link href={code === 'en' ? EN_URL : OTHER_URL}>{name}</Link>)
}

if (index != langs.length - 1) {
res.push(separator)
}

return res
}, [])
return (
<>
<Break />
<Break />
{res}
<Break />
<Break />
</>
)
}
import { linkObj, imageObj } from '../constants'
import { renderLanguage } from '../utils'

export default function Top() {
const props = {
Expand All @@ -45,7 +14,7 @@ export default function Top() {
<Image {...imageObj['logo']} />
</Link>
<Break />
{renderLanguage()}
{renderLanguage('README')}
<p style={{ fontSize: 18 }}>
{tr('适用于 JavaScript 的轻量、简单、灵活、自动翻译的国际化工具')}
</p>
Expand Down
42 changes: 38 additions & 4 deletions docs/src/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { getAnchor } from 'jsx-to-md'
import { Break, getAnchor, Link } from 'jsx-to-md'
import { initI18n as originInitI18n } from '@lib'
import { readFileSync } from 'fs'
import en from './i18n/en.json'
import packageInfo from '../../package.json'
import { langs } from './constants'

const { t, setI18n } = originInitI18n({ namespace: 'default' })

Expand All @@ -19,10 +20,14 @@ export function initI18n({ locale }) {
global.docLocale = locale
}

export function getDocHref(filename: string, anchorProp?: string) {
export function getDocHref(
filename: string,
anchorProp?: string,
localeProp?: string,
) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const { version: originVersion, codeNameMap, homepage } = packageInfo
const locale = global.docLocale
const locale = localeProp || global.docLocale
let name = codeNameMap[locale]
name = name ? `_${name}` : ''
const anchor = anchorProp ? getAnchor(anchorProp) : ''
Expand All @@ -37,7 +42,7 @@ export function getDocHref(filename: string, anchorProp?: string) {

if (filename === 'README') {
return locale === 'en'
? `${homepage}/tree/${version}${anchor}`
? `${homepage}/tree/${version}${anchor || '#readme'}`
: `${homepage}/blob/${version}/${filename}${name}.md${anchor}`
} else {
return `${homepage}/blob/${version}/docs/dist/${filename}${name}.md${anchor}`
Expand Down Expand Up @@ -118,3 +123,32 @@ t('${tr(
)}', 5, 4, 3) `
return text
}

export function renderLanguage(filename: string) {
const separator = ' | '

const res = langs.reduce((res, item, index) => {
const { code, name } = item

if (global.docLocale == code) {
res.push(name)
} else {
res.push(<Link href={getDocHref(filename, undefined, code)}>{name}</Link>)
}

if (index != langs.length - 1) {
res.push(separator)
}

return res
}, [])
return (
<>
<Break />
<Break />
{res}
<Break />
<Break />
</>
)
}

0 comments on commit 493e6a5

Please sign in to comment.