Skip to content

Commit

Permalink
[optimize] simplify i18n imports
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Nov 9, 2024
1 parent 602928b commit f2f216e
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 162 deletions.
4 changes: 1 addition & 3 deletions source/component/SummitCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import {
import { FC, observer } from 'web-cell';
import { isXDomain } from 'web-utility';

import { i18n } from '../i18n';
import { t } from '../i18n';
import { summits } from '../page/data';
import * as style from './SummitCard.module.less';

const { t } = i18n;

export type SummitCardProps = ReturnType<typeof summits>[0] & CardProps;

export const SummitCard: FC<SummitCardProps> = observer(
Expand Down
6 changes: 2 additions & 4 deletions source/component/TopNavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import { FC, observer } from 'web-cell';
import {
NavLink,
NavLinkProps,
OffcanvasNavbar,
OffcanvasNavbarProps
} from 'boot-cell';
import { FC, observer } from 'web-cell';

import { i18n, LanguageName } from '../i18n';
import { i18n, LanguageName, t } from '../i18n';

export interface TopNavBarProps extends OffcanvasNavbarProps {
menu?: NavLinkProps[];
}

const OriginalURLPattern = /^(https?|#)/;

const { t } = i18n;

export const TopNavBar: FC<TopNavBarProps> = observer(
({ menu = [], ...rest }) => (
<OffcanvasNavbar
Expand Down
2 changes: 2 additions & 0 deletions source/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const i18n = new TranslationModel({
'en-US': () => import('./en-US')
});

export const { t } = i18n;

export const LanguageName: Record<(typeof i18n)['currentLanguage'], string> = {
'zh-CN': '简体中文',
'zh-TW': '正體中文',
Expand Down
29 changes: 13 additions & 16 deletions source/page/2017/data.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import { t } from '../../i18n';
import avatars from './image/guests';
import {
QRGJ,
FCC_CDG,
BBD,
HCXY,
_3W,
DevEco,
BBD,
BW,
DevEco,
DKS,
FCC_CDG,
GDG,
GT,
SYL,
QE,
HCXY,
JueJin,
MZ,
OSChina,
QE,
QRGJ,
SF,
ZDK,
MZ,
GDG,
TW,
SYL,
TH,
TW,
WORK,
DKS
ZDK
} from './image/logos';

import { i18n } from '../../i18n';

const { t } = i18n;

export const title = () => t('chengdu_web_frontend_conference_2017');

export const guests = () => [
Expand Down
30 changes: 17 additions & 13 deletions source/page/2017/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Card, CardBody, CardImg, CardTitle, Button, Ratio } from 'boot-cell';
import { Button, Card, CardBody, CardImg, CardTitle, Ratio } from 'boot-cell';
import {
Accordion,
AccordionBody,
AccordionHeader,
AccordionItem
} from 'boot-cell';
import { i18n } from '../../i18n';
import { LogoList } from './LogoList';
import * as style from './index.module.less';
import { guests, flows, logos, title } from './data';
import { banner, qrcode } from './image';
import { observer } from 'web-cell';

const { t } = i18n;
import { t } from '../../i18n';
import { flows, guests, logos, title } from './data';
import { banner, qrcode } from './image';
import * as style from './index.module.less';
import { LogoList } from './LogoList';

export default () => (
<>
export default observer(() => (
<div>
<main className="container">
<header id={style.logo}>
<img className="w-100" src={banner} />
Expand All @@ -32,7 +32,7 @@ export default () => (
</h2>
<div className="row row-cols-1 row-cols-sm-2 row-cols-md-4 g-3">
{guests().map(({ avatar, name, description }) => (
<div className="col" key={name}>
<div key={name} className="col">
<Card id={'guest_' + name}>
<CardImg src={avatar} />
<CardBody>
Expand Down Expand Up @@ -106,7 +106,11 @@ export default () => (
<img className={style.qrcode} src={qrcode} />
<p className="mt-0">
{t('special_thanks')}&nbsp;
<a target="_blank" href="http://918930.lofter.com">
<a
target="_blank"
href="http://918930.lofter.com"
rel="noreferrer"
>
BBD - {t('wang_bo')}
</a>
&nbsp;
Expand All @@ -119,5 +123,5 @@ export default () => (
/>
</Ratio>
</footer>
</>
);
</div>
));
76 changes: 37 additions & 39 deletions source/page/2018-Code4City/data.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,55 @@
import gallery from './image/gallery';
import { i18n } from '../../i18n';
import { t } from '../../i18n';
import {
BBD,
DevEco,
DKS,
FCC_CDG,
GDG,
GT,
HCXY,
JueJin,
OSChina,
SYL
} from '../2017/image/logos';
import {
hushenquan,
fanxiaobin,
shenchangkun,
maoyufeng,
wenqixiang,
hushenquan,
liangtongming,
liwanpeng,
lvyan,
maoyufeng,
qinglinbo,
zhangwei,
liangtongming,
lvyan
shenchangkun,
wenqixiang,
zhangwei
} from './image/avatar';
import gallery from './image/gallery';
import {
cdht,
cdhttv,
cdkfx,
XinYaoHang,
JRsquare,
Monstarlab,
cdtv,
first,
fm940,
github,
Microsoft,
tap4fun,
jhspace,
SegmentFault,
ThoughtWorks,
tedxChengDu,
mikecrm,
first,
jintai,
JRsquare,
kct,
lvs,
yunpian,
Microsoft,
mikecrm,
Monstarlab,
scdaily,
sctv,
cdtv,
cdhttv,
SegmentFault,
sinasc,
scdaily,
fm940,
kct
tap4fun,
tedxChengDu,
ThoughtWorks,
XinYaoHang,
yunpian
} from './image/logo';
import {
FCC_CDG,
BBD,
GDG,
DevEco,
GT,
SYL,
HCXY,
JueJin,
OSChina,
DKS
} from '../2017/image/logos';

const { t } = i18n;

export const awards = () => [
{
Expand Down
15 changes: 7 additions & 8 deletions source/page/2018-Code4City/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { Container, Button, Image } from 'boot-cell';
import { Button, Container, Image } from 'boot-cell';
import { Carousel, CarouselCaption, CarouselItem } from 'boot-cell';
import { observer } from 'web-cell';

import { t } from '../../i18n';
import { awards, review, sponsors, vips } from './data';
import { GuestCard } from './GuestCard';
import * as style from './index.module.less';
import BG_mountain from './image/BG-mountain.png';
import BG_points from './image/BG-points.png';
import { review, awards, vips, sponsors } from './data';

import { i18n } from '../../i18n';
const { t } = i18n;
import * as style from './index.module.less';

export default () => (
export default observer(() => (
<main>
<div
className="text-light"
Expand Down Expand Up @@ -187,4 +186,4 @@ export default () => (
</Container>
</div>
</main>
);
));
40 changes: 19 additions & 21 deletions source/page/2018/data.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
import { t } from '../../i18n';
import { BW, JueJin, OSChina, SF, SYL } from '../2017/image/logos';
import { FCC_CDC } from './image';
import { JueJin, BW, SYL, OSChina, SF } from '../2017/image/logos';
import {
Guo_DaFeng,
Guo_LinShuo,
Huang_Yi,
Quincy_Larson,
Si_Yue,
Xiong_Jie,
Yu_Che
} from './image/lecturer';
import {
epubit,
fezaoduke,
mikecrm,
turing,
young,
mikecrm
young
} from './image/logo/partner';
import { BaiCiZhan, baozun, cocoet, sxl } from './image/logo/sponsor';
import {
Quincy_Larson,
Xiong_Jie,
Huang_Yi,
Si_Yue,
Yu_Che,
Guo_LinShuo,
Guo_DaFeng
} from './image/lecturer';
import {
CD_LUG,
Covariant_Script,
Deepin,
WebCell,
H5DS,
Fun_loading,
UKylin,
Covariant_Script,
H5DS,
KaiYuanShe,
PI6,
React_Admin,
KaiYuanShe,
UKylin,
Vena_Network,
CD_LUG
WebCell
} from './image/project';
import { i18n } from '../../i18n';

const { t } = i18n;

export const title = () => t('chengdu_web_frontend_conference_2018');

Expand Down
Loading

1 comment on commit f2f216e

@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 web-conf ready!

✅ Preview
https://web-conf-na8heya9l-techquerys-projects.vercel.app

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

Please sign in to comment.