Skip to content

Commit 4ab7058

Browse files
committed
feat(website): add translations (chinese, korean, japanese, german)
1 parent b5afab9 commit 4ab7058

File tree

504 files changed

+44290
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

504 files changed

+44290
-258
lines changed

packages/core/src/compiler.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
import { indent } from './indent.js';
1313
import { hasProperty } from './core.js';
1414

15-
declare var process: any;
15+
declare var process: {
16+
env: Record<string, string>;
17+
} | undefined;
1618

1719
const indentCode = ('undefined' !== typeof process && process.env?.DEBUG || '').includes('deepkit');
1820

packages/core/src/core.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ export function getInheritanceChain(classType: ClassType): ClassType[] {
464464
}
465465

466466
declare var v8debug: any;
467+
declare var process: {
468+
execArgv: string[];
469+
platform: string;
470+
} | undefined;
467471

468472
export function inDebugMode() {
469473
return typeof v8debug === 'object' ||
@@ -497,7 +501,7 @@ export function getCurrentFileName(offset: number = 0): string {
497501
if (path.indexOf('file') >= 0) {
498502
path = new URL(path).pathname;
499503
}
500-
if (path[0] === '/' && process.platform === 'win32') {
504+
if (path[0] === '/' && 'undefined' !== typeof process && process.platform === 'win32') {
501505
path = path.slice(1);
502506
}
503507
return path;

packages/core/tsconfig.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
"es2020",
2020
"es2022.error"
2121
],
22-
"types": [
23-
"dot-prop",
24-
"node"
25-
],
2622
"skipLibCheck": true
2723
},
2824
"reflection": true,
@@ -38,4 +34,4 @@
3834
"path": "../bench/tsconfig.json"
3935
}
4036
]
41-
}
37+
}

packages/http/src/router.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,7 @@
88
* You should have received a copy of the MIT License along with this program.
99
*/
1010
import { ClassType, CompilerContext, getClassName, isArray, isClass, urlJoin } from '@deepkit/core';
11-
import {
12-
entity,
13-
ReflectionClass,
14-
ReflectionFunction,
15-
ReflectionKind,
16-
ReflectionParameter,
17-
SerializationOptions,
18-
serializer,
19-
Serializer,
20-
Type,
21-
ValidationError,
22-
} from '@deepkit/type';
11+
import { entity, ReflectionClass, ReflectionFunction, ReflectionKind, ReflectionParameter, SerializationOptions, serializer, Serializer, Type, ValidationError } from '@deepkit/type';
2312
import { getActions, HttpAction, httpClass, HttpController, HttpDecorator } from './decorator.js';
2413
import { HttpRequest, HttpRequestPositionedParameters, HttpRequestQuery, HttpRequestResolvedParameters } from './model.js';
2514
import { InjectorContext, InjectorModule } from '@deepkit/injector';
@@ -30,7 +19,7 @@ import { HttpMiddlewareConfig, HttpMiddlewareFn } from './middleware.js';
3019

3120
//@ts-ignore
3221
import qs from 'qs';
33-
import { HtmlResponse, JSONResponse, Response } from './http.js';
22+
import { HtmlResponse, JSONResponse, Redirect, Response } from './http.js';
3423
import { getRequestParserCodeForParameters, ParameterForRequestParser, parseRoutePathToRegex } from './request-parser.js';
3524
import { HttpConfig } from './module.config.js';
3625

@@ -352,7 +341,7 @@ export interface HttpRouterFunctionOptions {
352341
function convertOptions(methods: string[], pathOrOptions: string | HttpRouterFunctionOptions, defaultOptions: Partial<HttpRouterFunctionOptions>): HttpRouterFunctionOptions {
353342
const options = 'string' === typeof pathOrOptions ? { path: pathOrOptions } : pathOrOptions;
354343
if (options.methods) return options;
355-
return { ...options, methods };
344+
return { ...defaultOptions, ...options, methods };
356345
}
357346

358347
/**
@@ -444,6 +433,13 @@ export abstract class HttpRouterRegistryFunctionRegistrar {
444433
this.register(convertOptions(['HEAD'], pathOrOptions, this.defaultOptions), callback);
445434
}
446435

436+
public redirectCallback(pathOrOptions: string | HttpRouterFunctionOptions, callback: (request: HttpRequest) => string, redirectCode: number = 302) {
437+
const options = convertOptions(['GET'], pathOrOptions, this.defaultOptions);
438+
this.register(options, (request: HttpRequest) => {
439+
return Redirect.toUrl(callback(request), redirectCode);
440+
});
441+
}
442+
447443
private register(options: HttpRouterFunctionOptions, callback: (...args: any[]) => any, module?: InjectorModule<any>) {
448444
const fn = ReflectionFunction.from(callback);
449445

@@ -536,7 +532,7 @@ export class HttpRouterRegistry extends HttpRouterRegistryFunctionRegistrar {
536532
type: 'controller',
537533
controller,
538534
module,
539-
methodName: action.methodName
535+
methodName: action.methodName,
540536
};
541537
const routeConfig = createRouteConfigFromHttpAction(routeAction, action, module, controllerData);
542538

@@ -578,7 +574,7 @@ export class HttpRouter {
578574
controllers: (ClassType | { module: InjectorModule<any>, controller: ClassType })[],
579575
middlewareRegistry: MiddlewareRegistry = new MiddlewareRegistry(),
580576
module: InjectorModule<any> = new InjectorModule(),
581-
config: HttpConfig = new HttpConfig()
577+
config: HttpConfig = new HttpConfig(),
582578
): HttpRouter {
583579
return new this(new HttpControllers(controllers.map(v => {
584580
return isClass(v) ? { controller: v, module } : v;
@@ -636,7 +632,7 @@ export class HttpRouter {
636632
resolverForToken: routeConfig.resolverForToken,
637633
resolverForParameterName: routeConfig.resolverForParameterName,
638634
pathParameterNames: parsedRoute.pathParameterNames,
639-
routeConfig
635+
routeConfig,
640636
});
641637

642638
let methodCheck = '';

packages/type/src/reflection/processor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ export class Processor {
688688
case ReflectionOp.parameter: {
689689
const ref = this.eatParameter() as number;
690690
const t: Type = { kind: ReflectionKind.parameter, parent: undefined as any, name: program.stack[ref] as string, type: this.pop() as Type };
691-
t.type.parent = t;
691+
if (t.type) t.type.parent = t;
692692
this.pushType(t);
693693
break;
694694
}

sync-tsconfig-deps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ for (const name of packages) {
4545
}
4646

4747
function filter(name) {
48-
return !['api-console-gui', 'framework-debug-gui', 'orm-browser-gui'].includes(name);
48+
return !['api-console-gui', 'framework-debug-gui', 'orm-browser-gui', 'desktop-ui'].includes(name);
4949
}
5050

5151
for (const [name, config] of Object.entries(packageConfigs)) {

tsconfig.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737
{
3838
"path": "./packages/create-app/tsconfig.json"
3939
},
40-
{
41-
"path": "./packages/desktop-ui/tsconfig.json"
42-
},
4340
{
4441
"path": "./packages/devtool/tsconfig.json"
4542
},
@@ -161,4 +158,4 @@
161158
"path": "./packages/workflow/tsconfig.json"
162159
}
163160
]
164-
}
161+
}

website/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ cd website/
1919
docker build -t website2 -f Dockerfile ../
2020
docker run --rm -p 8080:8080 -e app_databaseHost=host.docker.internal website2
2121
```
22+
23+
24+
## Translate
25+
26+
```sh
27+
export APP_OPENAI_API_KEY=your_openai_api_key
28+
npm run translate de
29+
```

website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"build": "npm run api-docs && BUILD=angular NODE_OPTIONS=--preserve-symlinks ng build --configuration production",
1111
"test": "jest"
1212
},
13+
"type": "commonjs",
1314
"private": true,
1415
"devDependencies": {
1516
"@angular-devkit/build-angular": "^20.0.3",

website/src/app/app.routes.ts

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
1-
import { ActivatedRouteSnapshot, CanActivate, Route, Routes } from '@angular/router';
1+
import { ActivatedRouteSnapshot, CanActivate, Route, Router, Routes, UrlMatcher, UrlSegment } from '@angular/router';
22
import { StartpageComponent } from '@app/app/pages/startpage.component';
33
import { DocumentationComponent } from '@app/app/pages/documentation.component';
44
import { EmptyComponent } from '@app/app/pages/empty.component';
5-
import { CommunityQuestionsComponent } from '@app/app/pages/documentation/community-questions.component';
65
import { DocumentationPageComponent } from '@app/app/pages/documentation/page.component';
7-
import { CommunityQuestionComponent } from '@app/app/pages/documentation/community-question.component';
8-
import { ExamplesComponent } from '@app/app/pages/documentation/examples.component';
9-
import { ExampleComponent } from '@app/app/pages/documentation/example.component';
10-
import { DocuSearchComponent } from '@app/app/pages/documentation/search.component';
116
import { StaticPageComponent } from '@app/app/pages/static-page.component';
127
import { NotFoundComponent } from '@app/app/pages/not-found.component';
138
import { Injectable } from '@angular/core';
149
import { BlogComponent, BlogListComponent, BlogPostDetailComponent } from '@app/app/pages/blog.component';
1510
import { BookComponent } from '@app/app/pages/documentation/book.component.js';
1611

12+
export const legacyDocMatcher: UrlMatcher = (segments: UrlSegment[]) => {
13+
if (segments.length === 0 || segments[0].path !== 'documentation') return null;
14+
const rest = segments.slice(1).map(s => s.path).join('/');
15+
return { consumed: segments, posParams: { rest: new UrlSegment(rest, {}) } };
16+
};
17+
18+
@Injectable({ providedIn: 'root' })
19+
export class LegacyDocRedirectGuard implements CanActivate {
20+
constructor(private router: Router) {}
21+
canActivate(route: ActivatedRouteSnapshot): false {
22+
const rest = (route.params['rest'] as string) || '';
23+
const target = rest ? `/en/documentation/${rest}` : `/en/documentation`;
24+
this.router.navigateByUrl(target, { replaceUrl: true });
25+
return false;
26+
}
27+
}
28+
1729
function redirect(from: string, to: string): Route {
1830
return {
1931
path: from,
@@ -36,12 +48,20 @@ export const routes: Routes = [
3648
redirect('documentation/type/serialization', 'documentation/runtime-types/serialization'),
3749
redirect('documentation/framework/rpc/controller', 'documentation/rpc/getting-started'),
3850

51+
{ path: 'documentation', pathMatch: 'full', redirectTo: 'en/documentation' },
52+
{ matcher: legacyDocMatcher, canActivate: [LegacyDocRedirectGuard], component: EmptyComponent },
53+
3954
// {
4055
// path: 'benchmarks',
4156
// loadChildren: () => import('./benchmarks/benchmarks.module').then(m => m.BenchmarksModule),
4257
// },
4358

44-
{ path: '', pathMatch: 'full', component: StartpageComponent, data: { floatHeader: true } },
59+
{ path: '', pathMatch: 'full', component: StartpageComponent },
60+
{ path: 'zh', pathMatch: 'full', component: StartpageComponent },
61+
{ path: 'ko', pathMatch: 'full', component: StartpageComponent },
62+
{ path: 'ja', pathMatch: 'full', component: StartpageComponent },
63+
{ path: 'de', pathMatch: 'full', component: StartpageComponent },
64+
4565
{ path: 'admin', loadComponent: () => import('./pages/admin/admin.component').then(v => v.AdminComponent) },
4666
// { path: 'library', component: LibrariesComponent },
4767
// { path: 'library/:id', component: LibraryComponent },
@@ -51,29 +71,29 @@ export const routes: Routes = [
5171
{ path: 'about-us', component: StaticPageComponent, data: { page: 'about-us' } },
5272
{ path: 'contact', component: StaticPageComponent, data: { page: 'contact' } },
5373
{ path: 'data-protection', component: StaticPageComponent, data: { page: 'data-protection' } },
54-
{ path: 'documentation/book', component: BookComponent },
74+
{ path: ':lang/documentation/book', component: BookComponent },
5575
{
56-
path: 'blog', component: BlogComponent, children: [
76+
path: ':lang/blog', component: BlogComponent, children: [
5777
{ path: '', pathMatch: 'full', component: BlogListComponent },
5878
{ path: ':slug', component: BlogPostDetailComponent },
5979
],
6080
},
6181
{
62-
path: 'documentation',
82+
path: ':lang/documentation',
6383
component: DocumentationComponent,
6484
data: { search: true, footer: false, hideLogo: true },
6585
children: [
66-
{
67-
path: 'questions', component: EmptyComponent, children: [
68-
{ path: 'post/:slug', component: CommunityQuestionComponent },
69-
{ path: '**', component: CommunityQuestionsComponent },
70-
],
71-
},
72-
{ path: 'search', component: DocuSearchComponent },
73-
{ path: 'examples', component: ExamplesComponent },
86+
// {
87+
// path: 'questions', component: EmptyComponent, children: [
88+
// { path: 'post/:slug', component: CommunityQuestionComponent },
89+
// { path: '**', component: CommunityQuestionsComponent },
90+
// ],
91+
// },
92+
// { path: 'search', component: DocuSearchComponent },
93+
// { path: 'examples', component: ExamplesComponent },
7494
{ path: 'desktop-ui', loadChildren: () => import('./pages/documentation/desktop-ui/desktop-ui.module').then(v => v.DocDesktopUIModule) },
75-
{ path: ':category/examples/:slug', component: ExampleComponent },
76-
{ path: ':category/examples', component: ExamplesComponent },
95+
// { path: ':category/examples/:slug', component: ExampleComponent },
96+
// { path: ':category/examples', component: ExamplesComponent },
7797
{ path: '**', component: DocumentationPageComponent },
7898
],
7999
},

0 commit comments

Comments
 (0)