Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update .gitignore file and i18n.md doc #4911

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading