Skip to content

Commit

Permalink
feat: Add .gitignore file and i18n.md documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
zjy365 committed Jul 19, 2024
1 parent ee997b2 commit 4df635a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ vendor
pkg/registry/save/testdata/registry
.dummy.report.md
deploy/cloud/tars
.vscode/
3 changes: 2 additions & 1 deletion frontend/.gitignore
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/
71 changes: 71 additions & 0 deletions frontend/i18n.md
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)

0 comments on commit 4df635a

Please sign in to comment.