Skip to content

Commit 2ee48b5

Browse files
authored
fix: migrate navigation data localization (#1081)
* fix: sub-navigation-data.ts has been moved * fix: migrate localization
1 parent 6f7e77f commit 2ee48b5

File tree

3 files changed

+197
-38
lines changed

3 files changed

+197
-38
lines changed

adev-ja/src/app/sub-navigation-data.en.ts renamed to adev-ja/src/app/routing/sub-navigation-data.en.ts

Lines changed: 85 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import {isDevMode} from '@angular/core';
1010
import {NavigationItem} from '@angular/docs';
1111

1212
// These 2 imports are expected to be red because they are generated a build time
13-
import FIRST_APP_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/first-app/routes.json';
14-
import LEARN_ANGULAR_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/learn-angular/routes.json';
15-
import DEFERRABLE_VIEWS_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/deferrable-views/routes.json';
16-
import SIGNALS_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/signals/routes.json';
17-
import ERRORS_NAV_DATA from '../../src/assets/content/reference/errors/routes.json';
18-
import EXT_DIAGNOSTICS_NAV_DATA from '../../src/assets/content/reference/extended-diagnostics/routes.json';
13+
import FIRST_APP_TUTORIAL_NAV_DATA from '../../../src/assets/tutorials/first-app/routes.json';
14+
import LEARN_ANGULAR_TUTORIAL_NAV_DATA from '../../../src/assets/tutorials/learn-angular/routes.json';
15+
import DEFERRABLE_VIEWS_TUTORIAL_NAV_DATA from '../../../src/assets/tutorials/deferrable-views/routes.json';
16+
import SIGNALS_TUTORIAL_NAV_DATA from '../../../src/assets/tutorials/signals/routes.json';
17+
import ERRORS_NAV_DATA from '../../../src/assets/content/reference/errors/routes.json';
18+
import EXT_DIAGNOSTICS_NAV_DATA from '../../../src/assets/content/reference/extended-diagnostics/routes.json';
1919

20-
import {getApiNavigationItems} from './features/references/helpers/manifest.helper';
21-
import {DEFAULT_PAGES} from './core/constants/pages';
20+
import {getApiNavigationItems} from '../features/references/helpers/manifest.helper';
21+
import {DEFAULT_PAGES} from '../core/constants/pages';
2222

2323
interface SubNavigationData {
2424
docs: NavigationItem[];
@@ -677,6 +677,66 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
677677
path: 'guide/drag-drop',
678678
contentPath: 'guide/drag-drop',
679679
},
680+
// TODO: unwrap to release Angular Aria docs.
681+
...(isDevMode()
682+
? [
683+
{
684+
label: 'Angular Aria',
685+
children: [
686+
{
687+
label: 'Overview',
688+
path: 'guide/aria/overview',
689+
contentPath: 'guide/aria/overview',
690+
},
691+
{
692+
label: 'Accordion',
693+
path: 'guide/aria/accordion',
694+
contentPath: 'guide/aria/accordion',
695+
},
696+
{
697+
label: 'Combobox',
698+
path: 'guide/aria/combobox',
699+
contentPath: 'guide/aria/combobox',
700+
},
701+
{
702+
label: 'Grid',
703+
path: 'guide/aria/grid',
704+
contentPath: 'guide/aria/grid',
705+
},
706+
{
707+
label: 'Listbox',
708+
path: 'guide/aria/listbox',
709+
contentPath: 'guide/aria/listbox',
710+
},
711+
{
712+
label: 'Menu',
713+
path: 'guide/aria/menu',
714+
contentPath: 'guide/aria/menu',
715+
},
716+
{
717+
label: 'Radio Group',
718+
path: 'guide/aria/radio',
719+
contentPath: 'guide/aria/radio',
720+
},
721+
{
722+
label: 'Tabs',
723+
path: 'guide/aria/tabs',
724+
contentPath: 'guide/aria/tabs',
725+
},
726+
{
727+
label: 'Toolbar',
728+
path: 'guide/aria/toolbar',
729+
contentPath: 'guide/aria/toolbar',
730+
},
731+
{
732+
label: 'Tree',
733+
path: 'guide/aria/tree',
734+
contentPath: 'guide/aria/tree',
735+
},
736+
],
737+
},
738+
]
739+
: []),
680740
],
681741
},
682742
{
@@ -985,6 +1045,11 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
9851045
path: 'ecosystem/service-workers/getting-started',
9861046
contentPath: 'ecosystem/service-workers/getting-started',
9871047
},
1048+
{
1049+
label: 'Custom service worker scripts',
1050+
path: 'ecosystem/service-workers/custom-service-worker-scripts',
1051+
contentPath: 'ecosystem/service-workers/custom-service-worker-scripts',
1052+
},
9881053
{
9891054
label: 'Configuration file',
9901055
path: 'ecosystem/service-workers/config',
@@ -1426,6 +1491,18 @@ const REFERENCE_SUB_NAVIGATION_DATA: NavigationItem[] = [
14261491
path: 'reference/migrations/self-closing-tags',
14271492
contentPath: 'reference/migrations/self-closing-tags',
14281493
},
1494+
{
1495+
label: 'NgClass to Class',
1496+
path: 'reference/migrations/ngclass-to-class',
1497+
contentPath: 'reference/migrations/ngclass-to-class',
1498+
status: 'new',
1499+
},
1500+
{
1501+
label: 'NgStyle to Style',
1502+
path: 'reference/migrations/ngstyle-to-style',
1503+
contentPath: 'reference/migrations/ngstyle-to-style',
1504+
status: 'new',
1505+
},
14291506
],
14301507
},
14311508
];

adev-ja/src/app/sub-navigation-data.ts renamed to adev-ja/src/app/routing/sub-navigation-data.ts

Lines changed: 91 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import {isDevMode} from '@angular/core';
1010
import {NavigationItem} from '@angular/docs';
1111

1212
// These 2 imports are expected to be red because they are generated a build time
13-
import FIRST_APP_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/first-app/routes.json';
14-
import LEARN_ANGULAR_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/learn-angular/routes.json';
15-
import DEFERRABLE_VIEWS_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/deferrable-views/routes.json';
16-
import SIGNALS_TUTORIAL_NAV_DATA from '../../src/assets/tutorials/signals/routes.json';
17-
import ERRORS_NAV_DATA from '../../src/assets/content/reference/errors/routes.json';
18-
import EXT_DIAGNOSTICS_NAV_DATA from '../../src/assets/content/reference/extended-diagnostics/routes.json';
13+
import FIRST_APP_TUTORIAL_NAV_DATA from '../../../src/assets/tutorials/first-app/routes.json';
14+
import LEARN_ANGULAR_TUTORIAL_NAV_DATA from '../../../src/assets/tutorials/learn-angular/routes.json';
15+
import DEFERRABLE_VIEWS_TUTORIAL_NAV_DATA from '../../../src/assets/tutorials/deferrable-views/routes.json';
16+
import SIGNALS_TUTORIAL_NAV_DATA from '../../../src/assets/tutorials/signals/routes.json';
17+
import ERRORS_NAV_DATA from '../../../src/assets/content/reference/errors/routes.json';
18+
import EXT_DIAGNOSTICS_NAV_DATA from '../../../src/assets/content/reference/extended-diagnostics/routes.json';
1919

20-
import {getApiNavigationItems} from './features/references/helpers/manifest.helper';
21-
import {DEFAULT_PAGES} from './core/constants/pages';
20+
import {getApiNavigationItems} from '../features/references/helpers/manifest.helper';
21+
import {DEFAULT_PAGES} from '../core/constants/pages';
2222

2323
interface SubNavigationData {
2424
docs: NavigationItem[];
@@ -396,17 +396,17 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
396396
contentPath: 'guide/routing/rendering-strategies',
397397
status: 'new',
398398
},
399-
{
400-
label: 'ルーターリファレンス',
401-
path: 'guide/routing/router-reference',
402-
contentPath: 'guide/routing/router-reference',
403-
},
404399
{
405400
label: 'ルートの動作のカスタマイズ',
406401
path: 'guide/routing/customizing-route-behavior',
407402
contentPath: 'guide/routing/customizing-route-behavior',
408403
status: 'new',
409404
},
405+
{
406+
label: 'ルーターリファレンス',
407+
path: 'guide/routing/router-reference',
408+
contentPath: 'guide/routing/router-reference',
409+
},
410410
{
411411
label: 'ルート遷移アニメーション',
412412
path: 'guide/routing/route-transition-animations',
@@ -672,11 +672,71 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
672672
},
673673
],
674674
},
675-
{
675+
{
676676
label: 'Drag and drop',
677677
path: 'guide/drag-drop',
678678
contentPath: 'guide/drag-drop',
679679
},
680+
// TODO: unwrap to release Angular Aria docs.
681+
...(isDevMode()
682+
? [
683+
{
684+
label: 'Angular Aria',
685+
children: [
686+
{
687+
label: 'Overview',
688+
path: 'guide/aria/overview',
689+
contentPath: 'guide/aria/overview',
690+
},
691+
{
692+
label: 'Accordion',
693+
path: 'guide/aria/accordion',
694+
contentPath: 'guide/aria/accordion',
695+
},
696+
{
697+
label: 'Combobox',
698+
path: 'guide/aria/combobox',
699+
contentPath: 'guide/aria/combobox',
700+
},
701+
{
702+
label: 'Grid',
703+
path: 'guide/aria/grid',
704+
contentPath: 'guide/aria/grid',
705+
},
706+
{
707+
label: 'Listbox',
708+
path: 'guide/aria/listbox',
709+
contentPath: 'guide/aria/listbox',
710+
},
711+
{
712+
label: 'Menu',
713+
path: 'guide/aria/menu',
714+
contentPath: 'guide/aria/menu',
715+
},
716+
{
717+
label: 'Radio Group',
718+
path: 'guide/aria/radio',
719+
contentPath: 'guide/aria/radio',
720+
},
721+
{
722+
label: 'Tabs',
723+
path: 'guide/aria/tabs',
724+
contentPath: 'guide/aria/tabs',
725+
},
726+
{
727+
label: 'Toolbar',
728+
path: 'guide/aria/toolbar',
729+
contentPath: 'guide/aria/toolbar',
730+
},
731+
{
732+
label: 'Tree',
733+
path: 'guide/aria/tree',
734+
contentPath: 'guide/aria/tree',
735+
},
736+
],
737+
},
738+
]
739+
: []),
680740
],
681741
},
682742
{
@@ -985,6 +1045,11 @@ const DOCS_SUB_NAVIGATION_DATA: NavigationItem[] = [
9851045
path: 'ecosystem/service-workers/getting-started',
9861046
contentPath: 'ecosystem/service-workers/getting-started',
9871047
},
1048+
{
1049+
label: '独自のService Workerスクリプト',
1050+
path: 'ecosystem/service-workers/custom-service-worker-scripts',
1051+
contentPath: 'ecosystem/service-workers/custom-service-worker-scripts',
1052+
},
9881053
{
9891054
label: '設定ファイル',
9901055
path: 'ecosystem/service-workers/config',
@@ -1434,6 +1499,18 @@ const REFERENCE_SUB_NAVIGATION_DATA: NavigationItem[] = [
14341499
path: 'reference/migrations/self-closing-tags',
14351500
contentPath: 'reference/migrations/self-closing-tags',
14361501
},
1502+
{
1503+
label: 'NgClass to Class',
1504+
path: 'reference/migrations/ngclass-to-class',
1505+
contentPath: 'reference/migrations/ngclass-to-class',
1506+
status: 'new',
1507+
},
1508+
{
1509+
label: 'NgStyle to Style',
1510+
path: 'reference/migrations/ngstyle-to-style',
1511+
contentPath: 'reference/migrations/ngstyle-to-style',
1512+
status: 'new',
1513+
},
14371514
],
14381515
},
14391516
];

tools/update-origin.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import { parseArgs } from 'node:util';
66
import { cpRf, exists } from './lib/fsutils';
77
import { adevJaDir, rootDir } from './lib/workspace';
88

9-
const localizedFilePatterns = [
9+
const localizedFilePatterns: Array<string | readonly string[]> = [
1010
// Text contents
11-
'src/content/**/*.md',
12-
'!src/content/**/license.md',
11+
['src/content/**/*.md', '!src/content/**/license.md'],
1312
// Tutorial config files
1413
'src/content/tutorials/**/config.json',
1514
// Update home files
@@ -19,10 +18,10 @@ const localizedFilePatterns = [
1918
'src/app/features/update/update.component.ts',
2019
'src/app/features/update/update.component.html',
2120
// Application files
22-
'src/app/sub-navigation-data.ts',
21+
'src/app/routing/sub-navigation-data.ts',
2322
'src/app/core/layout/navigation/navigation.component.html',
2423
'shared-docs/components/table-of-contents/table-of-contents.component.html',
25-
'shared-docs/components/cookie-popup/cookie-popup.component.html'
24+
'shared-docs/components/cookie-popup/cookie-popup.component.html',
2625
];
2726

2827
async function main() {
@@ -50,20 +49,26 @@ async function resetOrigin(hash: string) {
5049

5150
async function copyOriginFiles() {
5251
const adevDir = resolve(rootDir, 'origin/adev');
53-
const adevFiles = await glob(localizedFilePatterns, {
54-
cwd: adevDir,
55-
caseSensitiveMatch: true,
56-
});
5752

5853
// adev-ja 内に同名ファイルの .en.xxx がある場合はそちらを上書きする
5954
// .en.xxx がない場合はそのままコピーする
60-
for (const file of adevFiles) {
61-
const src = resolve(adevDir, file);
62-
const ext = extname(file);
63-
const enFilePath = file.replace(`${ext}`, `.en${ext}`);
64-
const isTranslated = await exists(resolve(adevJaDir, enFilePath));
65-
const dest = resolve(adevJaDir, isTranslated ? enFilePath : file);
66-
await cpRf(src, dest);
55+
for (const pattern of localizedFilePatterns) {
56+
const files = await glob(pattern, {
57+
cwd: adevDir,
58+
caseSensitiveMatch: true,
59+
});
60+
// 否定パターンではなくパターンに合致するファイルがまったくない場合はエラーとする。
61+
if (files.length === 0) {
62+
throw new Error(`No files matched: ${JSON.stringify(pattern)}`);
63+
}
64+
for (const file of files) {
65+
const src = resolve(adevDir, file);
66+
const ext = extname(file);
67+
const enFilePath = file.replace(`${ext}`, `.en${ext}`);
68+
const isTranslated = await exists(resolve(adevJaDir, enFilePath));
69+
const dest = resolve(adevJaDir, isTranslated ? enFilePath : file);
70+
await cpRf(src, dest);
71+
}
6772
}
6873
}
6974

0 commit comments

Comments
 (0)