-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add .gitignore file and i18n.md documentation
- Loading branch information
Showing
3 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ vendor | |
pkg/registry/save/testdata/registry | ||
.dummy.report.md | ||
deploy/cloud/tars | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
.next | ||
.env*.local | ||
next-env.d.ts | ||
next-env.d.ts | ||
!.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
## I18N | ||
|
||
### Install i18n-ally Plugin | ||
|
||
1. Open the Extensions Marketplace in VSCode, search for and install the `i18n Ally` plugin. | ||
|
||
### Code Optimization Examples | ||
|
||
#### Fetch Specific Namespace Translations in `getServerSideProps` | ||
|
||
```typescript | ||
// pages/yourPage.tsx | ||
export async function getServerSideProps(context: any) { | ||
return { | ||
props: { | ||
currentTab: context?.query?.currentTab || TabEnum.info, | ||
...(await serverSideTranslations(context.locale, ['publish', 'user'])) | ||
} | ||
}; | ||
} | ||
``` | ||
|
||
#### Use useTranslation Hook in Page | ||
|
||
```typescript | ||
// pages/yourPage.tsx | ||
import { useTranslation } from 'next-i18next'; | ||
|
||
const YourComponent = () => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Button variant="outline" size="sm" mr={2} onClick={() => setShowSelected(false)}> | ||
{t('common:close')} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default YourComponent; | ||
``` | ||
#### Handle Static File Translations | ||
```typescript | ||
// utils/i18n.ts | ||
import { i18nT } from '@packages/i18n/utils'; | ||
|
||
const staticContent = { | ||
id: 'simpleChat', | ||
avatar: 'core/workflow/template/aiChat', | ||
name: i18nT('app:template.simple_robot') | ||
}; | ||
|
||
export default staticContent; | ||
``` | ||
### Standardize Translation Format | ||
- Use the t(namespace:key) format to ensure consistent naming. | ||
- Translation keys should use lowercase letters and underscores, e.g., common.close. | ||
### Translation File Paths | ||
- Desktop: [Desktop Translation Files](./desktop/public/locales) | ||
- App Launchpad: [App Launchpad Translation Files](./providers/applaunchpad/public/locales) | ||
- Database: [Database Translation Files](./providers/dbprovider/public/locales) | ||
- App Store: [App Store Translation Files](./providers/template/public/locales) | ||
- Cost Center: [Cost Center Translation Files](./providers/costcenter/public/locales) | ||
- Object Storage: [Object Storage Translation Files](./providers/objectstorage/public/locales) | ||
- Cron Jobs: [Cron Jobs Translation Files](./providers/cronjob/public/locales) | ||
- Cloud Server: [Cloud Server Translation Files](./providers/cloudserver/public/locales) |