2024-11-29 21:55:15 +00:00
|
|
|
# README
|
2024-10-25 14:12:35 +00:00
|
|
|
|
2024-11-29 21:55:15 +00:00
|
|
|
Frontend for _upda_.
|
2024-10-25 14:12:35 +00:00
|
|
|
|
2024-11-29 21:55:15 +00:00
|
|
|
## Configuration
|
2024-10-25 14:12:35 +00:00
|
|
|
|
2024-11-29 21:55:15 +00:00
|
|
|
* During development: `.env.development`
|
|
|
|
* Production derives the values from their main GoLang application, some environment variables are coupled with their
|
|
|
|
backend one, some are exposed via `WEB_*`, but internally mapped to `VITE_` in the `app.go` file
|
2024-10-25 14:12:35 +00:00
|
|
|
|
|
|
|
## Development & contribution
|
|
|
|
|
|
|
|
Contributions are very welcome!
|
|
|
|
|
|
|
|
### Prerequisites
|
|
|
|
|
|
|
|
It's probably worth checking out a node environment manager like [nvm manager](https://github.com/nvm-sh/nvm).
|
|
|
|
|
2024-12-10 19:52:35 +00:00
|
|
|
Required node and npm versions are outlined in the `package.json` in the `"engines"` section.
|
|
|
|
|
|
|
|
The application uses `pnpm`. Make sure to install it. For this you can use your global npm installation and invoke
|
|
|
|
`npm install --global pnpm@^9` or have it as system package.
|
2024-10-25 14:12:35 +00:00
|
|
|
|
|
|
|
### Setup instructions
|
|
|
|
|
2024-12-10 19:52:35 +00:00
|
|
|
Run `pnpm install` which should install all dependencies.
|
2024-10-25 14:12:35 +00:00
|
|
|
|
|
|
|
### Start
|
|
|
|
|
2024-12-10 19:52:35 +00:00
|
|
|
Use the `pnpm start` command to start the development setup. Backend should be running.
|
2024-10-25 14:12:35 +00:00
|
|
|
|
2024-11-29 21:55:15 +00:00
|
|
|
### Translation files
|
2024-10-25 14:12:35 +00:00
|
|
|
|
2024-12-10 19:52:35 +00:00
|
|
|
Pipeline checks for existing i18n keys, if you need to manually sync any language file, run `pnpm i18n-sync`.
|
2024-10-25 14:12:35 +00:00
|
|
|
|
2024-12-01 10:38:43 +00:00
|
|
|
#### New translation languages
|
|
|
|
|
|
|
|
Adapt `package.json` and add the respective key to `i18n-sync` and `checkstyle:i18n` for the `--languages` argument,
|
|
|
|
e.g. `--languages en,new`.
|
|
|
|
|
2024-12-10 19:52:35 +00:00
|
|
|
Run `pnpm i18n-sync` to create and sync new language
|
2024-12-01 10:38:43 +00:00
|
|
|
|
|
|
|
Adapt `languages.ts`
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
enum Languages {
|
|
|
|
// ...
|
|
|
|
NEW = 'new'
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Adapt `locales.ts`
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
enum Locales {
|
|
|
|
// ...
|
|
|
|
NEW = 'new-NEW'
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Adapt `LocaleProvider.tsx` to detect the new language, assign proper _momentjs_ locale.
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
// add import for Ant Design
|
|
|
|
import new_NEW from 'antd/lib/locale/new_NEW';
|
|
|
|
|
|
|
|
// add import for moment
|
|
|
|
// @ts-ignore
|
|
|
|
import new_localization from 'moment/dist/locale/new.js';
|
|
|
|
|
|
|
|
// getLocaleFromLanguage
|
|
|
|
if (LANGUAGES.NEW === language) {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
// getLanguageFromLocale
|
|
|
|
if (LANGUAGES.NEW === language) {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
// setLocales (uses import of moment)
|
|
|
|
// ...
|
|
|
|
else if (Languages.NEW === language) {
|
|
|
|
// use import for Ant Design
|
|
|
|
setAntLocale(new_NEW);
|
|
|
|
// use import for moment
|
|
|
|
moment.updateLocale(language, de_localization);
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Adapt `i18n/index.ts` and import new language and make i18n detect it (locales are derived from it)
|
|
|
|
|
|
|
|
```typescript jsx
|
|
|
|
import newTranslation from './translations/new.json';
|
|
|
|
|
|
|
|
const resources = {
|
|
|
|
//...
|
|
|
|
new: {
|
|
|
|
...newTranslation
|
|
|
|
}
|
|
|
|
};
|
|
|
|
```
|
|
|
|
|
2024-11-29 21:55:15 +00:00
|
|
|
### Dependencies
|
2024-10-25 14:12:35 +00:00
|
|
|
|
2024-11-29 21:55:15 +00:00
|
|
|
To track unused dependencies
|
2024-10-25 14:12:35 +00:00
|
|
|
|
2024-11-29 21:55:15 +00:00
|
|
|
```shell
|
|
|
|
# install (if not yet present)
|
2024-12-10 19:52:35 +00:00
|
|
|
npm install --global depcheck typescript
|
2024-10-25 14:12:35 +00:00
|
|
|
|
2024-11-29 21:55:15 +00:00
|
|
|
# run
|
|
|
|
depcheck
|
|
|
|
```
|
2024-12-10 19:52:35 +00:00
|
|
|
|
|
|
|
To manage (outdated) dependencies, `pnpm` helps:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
# shows outdated dependencies
|
|
|
|
pnpm outdated
|
|
|
|
|
|
|
|
# upgrades to latest in range definition of package.json
|
|
|
|
pnpm up
|
|
|
|
|
|
|
|
# upgrades to latest available, this includes major upgrades
|
|
|
|
pnpm up --latest
|
|
|
|
```
|