Skip to content

Commit

Permalink
refactor(i18n): modularize and shard by feature (#7134)
Browse files Browse the repository at this point in the history
* refactor(i18n): move locale files to specific directories

Prepare for sharding up of locale resources by moving each locale into
its own directory. Use this as the base to manage future growth and
expansion of locale resources to cover most text in FormSG.

No code change.

* refactor(i18n): add features dir, shard login locale

Hold feature-specific locale resources in a `features/` dir for each
locale, to minimise clutter even as we add more text to hold as
resources.

* refactor(i18n): reorg translations by feature, not locale
  • Loading branch information
LoneRifle authored Mar 15, 2024
1 parent 51f538d commit 51972bb
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 41 deletions.
16 changes: 2 additions & 14 deletions frontend/src/i18n/locales/en-sg.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { enSG as login } from './features/login'
import Translation from './types'

export const enSG: Translation = {
translation: {
features: {
login: {
LoginPage: {
slogan: 'Build secure government forms in minutes',
},
components: {
LoginForm: {
onlyAvailableForPublicOfficers:
'Log in with a .gov.sg or other whitelisted email address',
emailEmptyErrorMsg: 'Please enter an email address',
login: 'Log in',
haveAQuestion: 'Have a question?',
},
},
},
login,
},
},
}
16 changes: 16 additions & 0 deletions frontend/src/i18n/locales/features/login/en-sg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Login } from '.'

export const enSG: Login = {
LoginPage: {
slogan: 'Build secure government forms in minutes',
},
components: {
LoginForm: {
onlyAvailableForPublicOfficers:
'Log in with a .gov.sg or other whitelisted email address',
emailEmptyErrorMsg: 'Please enter an email address',
login: 'Log in',
haveAQuestion: 'Have a question?',
},
},
}
16 changes: 16 additions & 0 deletions frontend/src/i18n/locales/features/login/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export * from './en-sg'
export * from './zh-sg'

export interface Login {
components: {
LoginForm: {
onlyAvailableForPublicOfficers: string
emailEmptyErrorMsg: string
login: string
haveAQuestion: string
}
}
LoginPage: {
slogan: string
}
}
16 changes: 16 additions & 0 deletions frontend/src/i18n/locales/features/login/zh-sg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Login } from '.'

export const zhSG: Login = {
LoginPage: {
slogan: '在几分钟内创建安全的政府表格',
},
components: {
LoginForm: {
onlyAvailableForPublicOfficers:
'只供拥有 gov.sg 或其他列入白名单的电子邮件的公职人员使用',
emailEmptyErrorMsg: '请输入电子邮件地址',
login: '登录',
haveAQuestion: '有问题?',
},
},
}
16 changes: 3 additions & 13 deletions frontend/src/i18n/locales/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import { Login } from './features/login'

interface Translation {
translation: {
features: {
login: {
components: {
LoginForm: {
onlyAvailableForPublicOfficers: string
emailEmptyErrorMsg: string
login: string
haveAQuestion: string
}
}
LoginPage: {
slogan: string
}
}
login: Login
}
}
}
Expand Down
16 changes: 2 additions & 14 deletions frontend/src/i18n/locales/zh-sg.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { zhSG as login } from './features/login'
import Translation from './types'

export const zhSG: Translation = {
translation: {
features: {
login: {
LoginPage: {
slogan: '在几分钟内创建安全的政府表格',
},
components: {
LoginForm: {
onlyAvailableForPublicOfficers:
'只供拥有 gov.sg 或其他列入白名单的电子邮件的公职人员使用',
emailEmptyErrorMsg: '请输入电子邮件地址',
login: '登录',
haveAQuestion: '有问题?',
},
},
},
login,
},
},
}

0 comments on commit 51972bb

Please sign in to comment.