Skip to content

Commit

Permalink
git page i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
luojiyin1987 committed Jul 11, 2024
1 parent 7373ae1 commit cf5fa4f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
21 changes: 12 additions & 9 deletions components/Git/ArticleEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import { blobOf, formatDate, uniqueID } from 'web-utility';
import YAML from 'yaml';

import { GitRepositoryModel, userStore } from '../../models/Repository';
import { i18n } from '../../models/Translation';
import { ListField } from '../Form/JSONEditor';
import { PathSelect } from './PathSelect';
import { RepositorySelect } from './RepositorySelect';

const { t } = i18n;
const HTMLEditor = dynamic(() => import('../Form/HTMLEditor'), { ssr: false });

export const fileType = {
Expand Down Expand Up @@ -119,7 +121,6 @@ export class ArticleEditor extends Component {

reset = () => {
this.meta = null;

this.editorContent = '';
};

Expand Down Expand Up @@ -249,39 +250,41 @@ export class ArticleEditor extends Component {
onSubmit={this.submit}
>
<Form.Group className="row">
<label className="col-sm-2 col-form-label">Repository</label>
<label className="col-sm-2 col-form-label">{t('repository')}</label>
<RepositorySelect
onChange={({ owner, name }) =>
(this.repository = `${owner}/${name}`)
}
/>
</Form.Group>
<Form.Group className="row">
<label className="col-sm-2 col-form-label">File path</label>
<label className="col-sm-2 col-form-label">{t('filePath')}</label>

{repository && (
<PathSelect repository={repository} onChange={this.loadFile} />
)}
</Form.Group>
<Form.Group className="row align-items-center">
<label className="col-sm-2 col-form-label">Commit message</label>
<label className="col-sm-2 col-form-label">
{t('commitMessage')}
</label>
<Col sm={7}>
<Form.Control as="textarea" name="message" required />
</Col>
<Col
sm={3}
className="d-flex flex-wrap gap-2 justify-content-around align-items-center"
>
<Button type="submit">Commit</Button>
<Button type="submit">{t('commit')}</Button>
<Button type="reset" variant="danger">
Clear
{t('clear')}
</Button>
</Col>
</Form.Group>

{meta && (
<Form.Group>
<label>Meta</label>
<label>{t('meta')}</label>
<ListField
value={meta}
onChange={({ currentTarget: { value } }) =>
Expand All @@ -292,14 +295,14 @@ export class ArticleEditor extends Component {
)}
<Form.Group onInput={this.fixURL}>
<div className="d-flex justify-content-between align-items-center my-2">
<label>Content</label>
<label>{t('content')}</label>
<Button
variant="secondary"
size="sm"
onClick={this.copyMarkdown}
onBlur={() => (this.copied = false)}
>
{copied ? '√' : ''} Copy MarkDown
{copied ? '√' : ''} {t('copyMarkDown')}
</Button>
</div>
<HTMLEditor
Expand Down
10 changes: 10 additions & 0 deletions translation/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,14 @@ export default {
range_file: 'file',
range_module: 'module',
last_step: 'back',

// git pager
repository: 'repository',
filePath: 'filePath',
commitMessage: 'commit Message',
commit: 'commit',
clear: 'clear',
meta: 'meta',
content: 'content',
copyMarkDown: 'copy Markdown',
} as const;
10 changes: 10 additions & 0 deletions translation/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,14 @@ export default {
range_file: '文件',
range_module: '模块',
last_step: '上一步',

// git pager
repository: '代码仓库',
filePath: '文件路径',
commitMessage: '提交信息',
commit: '提交',
clear: '清空',
meta: '元数据',
content: '内容',
copyMarkDown: '复制 Markdown',
} as const;
10 changes: 10 additions & 0 deletions translation/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,14 @@ export default {
range_file: '檔案',
range_module: '模組',
last_step: '上一步',

// git pager
repository: '程式碼倉庫',
filePath: '檔案路徑',
commitMessage: '提交訊息',
commit: '提交',
clear: '清空',
meta: '詮釋資料',
content: '内容',
copyMarkDown: '複製 Markdown',
} as const;

1 comment on commit cf5fa4f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for oss-toolbox ready!

✅ Preview
https://oss-toolbox-qo5ay2vhe-techquerys-projects.vercel.app

Built with commit cf5fa4f.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.