From b96af66643a7206949b1a782da1cbc7a0e277c30 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Fri, 1 Dec 2023 09:40:45 -0800 Subject: [PATCH 1/8] Fix test to match new service behavior --- src/app/services/translateProjectService.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/services/translateProjectService.spec.ts b/src/app/services/translateProjectService.spec.ts index 80ecff07edd..648307233d8 100644 --- a/src/app/services/translateProjectService.spec.ts +++ b/src/app/services/translateProjectService.spec.ts @@ -31,7 +31,7 @@ describe('TranslateProjectService', () => { spyOn(projectService, 'getLocale').and.returnValue(new ProjectLocale()); }); it('should keep original project in tact', () => { - service.translate().subscribe(() => { + service.translate().then(() => { expect(projectService.getProjectTitle()).toEqual('Demo Project'); }); }); @@ -44,7 +44,7 @@ describe('TranslateProjectService', () => { spyOn(configService, 'getConfigParam').and.returnValue('/123/project.json'); }); it('should retrieve translation mapping file and translate project', () => { - service.translate('es').subscribe(() => { + service.translate('es').then(() => { expect(projectService.getProjectTitle()).toEqual('Proyecto de demostraciĆ³n'); }); http From f3f274efd805391878b33aae61c71c502860adf1 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Fri, 1 Dec 2023 09:41:30 -0800 Subject: [PATCH 2/8] Add language settings options in AT project info page Allow users to select default language and supported languages --- package-lock.json | 18 +++++ package.json | 1 + src/app/domain/localeToLanguage.ts | 10 ++- src/app/domain/projectLocale.ts | 33 +++++---- src/app/teacher/authoring-tool.module.ts | 4 ++ .../project-info-authoring.component.html | 5 +- ...it-project-language-setting.component.html | 19 +++++ ...it-project-language-setting.component.scss | 0 ...project-language-setting.component.spec.ts | 31 ++++++++ ...edit-project-language-setting.component.ts | 36 ++++++++++ src/messages.xlf | 72 +++++++++++++++++-- src/style/styles.scss | 1 + 12 files changed, 208 insertions(+), 22 deletions(-) create mode 100644 src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html create mode 100644 src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.scss create mode 100644 src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.spec.ts create mode 100644 src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.ts diff --git a/package-lock.json b/package-lock.json index f48702951c1..724405b5057 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "@angular/platform-browser": "^16.2.9", "@angular/platform-browser-dynamic": "^16.2.9", "@angular/router": "^16.2.9", + "@ng-select/ng-select": "^11.2.0", "@ng-web-apis/common": "^2.0.1", "@ng-web-apis/intersection-observer": "^3.0.0", "@stomp/rx-stomp": "^1.1.4", @@ -5061,6 +5062,23 @@ "tslib": "^2.1.0" } }, + "node_modules/@ng-select/ng-select": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/@ng-select/ng-select/-/ng-select-11.2.0.tgz", + "integrity": "sha512-lTyw93kFdKGecp9eKmOP0PQSCaAJS8DCt4D60ns055+ixvRSp2fuXAuJUvn1e3gAsvpZor37osmYlOJ4LYwYIA==", + "dependencies": { + "tslib": "^2.3.1" + }, + "engines": { + "node": ">= 16", + "npm": ">= 8" + }, + "peerDependencies": { + "@angular/common": "^16.0.0", + "@angular/core": "^16.0.0", + "@angular/forms": "^16.0.0" + } + }, "node_modules/@ng-web-apis/common": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@ng-web-apis/common/-/common-2.2.0.tgz", diff --git a/package.json b/package.json index bf169ebeeb6..5b2b871b218 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@angular/platform-browser": "^16.2.9", "@angular/platform-browser-dynamic": "^16.2.9", "@angular/router": "^16.2.9", + "@ng-select/ng-select": "^11.2.0", "@ng-web-apis/common": "^2.0.1", "@ng-web-apis/intersection-observer": "^3.0.0", "@stomp/rx-stomp": "^1.1.4", diff --git a/src/app/domain/localeToLanguage.ts b/src/app/domain/localeToLanguage.ts index c66d368e73d..324bd01856d 100644 --- a/src/app/domain/localeToLanguage.ts +++ b/src/app/domain/localeToLanguage.ts @@ -1,6 +1,12 @@ -export const localeToLanguage = { +export const localeToLanguage: { [locale: string]: string } = { en_US: $localize`English`, es: $localize`Spanish`, + de: $localize`German`, ja: $localize`Japanese`, - it: $localize`Italian` + it: $localize`Italian`, + ko: $localize`Korean`, + nl: $localize`Dutch (Netherlands)`, + vi: $localize`Vietnamese`, + zh_CN: $localize`Chinese (Simplified)`, + zh_TW: $localize`Chinese (Traditional)` }; diff --git a/src/app/domain/projectLocale.ts b/src/app/domain/projectLocale.ts index 862302fd771..7ffdd4fff3f 100644 --- a/src/app/domain/projectLocale.ts +++ b/src/app/domain/projectLocale.ts @@ -1,32 +1,39 @@ import { Language } from './language'; import { localeToLanguage } from './localeToLanguage'; -const defaultLocales = { - default: 'en_US', - supported: [] -}; +const defaultProjectLocale = { default: 'en_US', supported: [] }; export class ProjectLocale { - private default: string; - private supported: string[]; + private locale: { default: string; supported: string[] }; - constructor(locales: any = defaultLocales) { - this.default = locales.default; - this.supported = locales.supported; + constructor(locale: any = defaultProjectLocale) { + this.locale = locale; + } + + getDefaultLanguage(): Language { + return { language: localeToLanguage[this.locale.default], locale: this.locale.default }; + } + + setDefaultLocale(locale: string): void { + this.locale.default = locale; } getSupportedLanguages(): Language[] { - return this.supported.map((locale) => ({ + return this.locale.supported.map((locale) => ({ language: localeToLanguage[locale], locale: locale })); } + setSupportedLanguages(languages: Language[]): void { + this.locale.supported = languages.map((language) => language.locale); + } + private hasLocale(locale: string): boolean { - return this.supported.includes(locale); + return this.locale.supported.includes(locale); } hasTranslations(): boolean { - return this.supported.length > 1; + return this.locale.supported.length > 1; } hasTranslationsToApply(locale: string): boolean { @@ -34,6 +41,6 @@ export class ProjectLocale { } isDefaultLocale(locale: string): boolean { - return this.default === locale; + return this.locale.default === locale; } } diff --git a/src/app/teacher/authoring-tool.module.ts b/src/app/teacher/authoring-tool.module.ts index cc52db94ffa..2346c5fe6e6 100644 --- a/src/app/teacher/authoring-tool.module.ts +++ b/src/app/teacher/authoring-tool.module.ts @@ -1,5 +1,6 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; +import { NgSelectModule } from '@ng-select/ng-select'; import { AddYourOwnNode } from '../../assets/wise5/authoringTool/addNode/add-your-own-node/add-your-own-node.component'; import { ChooseNewNodeLocation } from '../../assets/wise5/authoringTool/addNode/choose-new-node-location/choose-new-node-location.component'; import { ChooseNewNodeTemplate } from '../../assets/wise5/authoringTool/addNode/choose-new-node-template/choose-new-node-template.component'; @@ -56,6 +57,7 @@ import { ComponentTypeButtonComponent } from '../../assets/wise5/authoringTool/c import { ComponentInfoDialogComponent } from '../../assets/wise5/authoringTool/components/component-info-dialog/component-info-dialog.component'; import { ComponentTypeSelectorComponent } from '../../assets/wise5/authoringTool/components/component-type-selector/component-type-selector.component'; import { EditNodeTitleComponent } from '../../assets/wise5/authoringTool/node/edit-node-title/edit-node-title.component'; +import { EditProjectLanguageSettingComponent } from '../../assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component'; @NgModule({ declarations: [ @@ -85,6 +87,7 @@ import { EditNodeTitleComponent } from '../../assets/wise5/authoringTool/node/ed ConcurrentAuthorsMessageComponent, ConfigureAutomatedAssessmentComponent, EditNodeTitleComponent, + EditProjectLanguageSettingComponent, InsertNodeAfterButtonComponent, InsertNodeInsideButtonComponent, MilestonesAuthoringComponent, @@ -111,6 +114,7 @@ import { EditNodeTitleComponent } from '../../assets/wise5/authoringTool/node/ed MatBadgeModule, MatChipsModule, ImportComponentModule, + NgSelectModule, NodeAdvancedAuthoringModule, PreviewComponentModule, ProjectAssetAuthoringModule, diff --git a/src/assets/wise5/authoringTool/project-info-authoring/project-info-authoring.component.html b/src/assets/wise5/authoringTool/project-info-authoring/project-info-authoring.component.html index 104e922a9d7..204472394ae 100644 --- a/src/assets/wise5/authoringTool/project-info-authoring/project-info-authoring.component.html +++ b/src/assets/wise5/authoringTool/project-info-authoring/project-info-authoring.component.html @@ -52,7 +52,10 @@ (ngModelChange)="metadataChanged.next()" /> - + + diff --git a/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html new file mode 100644 index 00000000000..f62584fd5d6 --- /dev/null +++ b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html @@ -0,0 +1,19 @@ +

Language

+Default language: + + +Additional languages: + + diff --git a/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.scss b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.scss new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.spec.ts b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.spec.ts new file mode 100644 index 00000000000..801f53853d4 --- /dev/null +++ b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.spec.ts @@ -0,0 +1,31 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { NgSelectModule } from '@ng-select/ng-select'; +import { EditProjectLanguageSettingComponent } from './edit-project-language-setting.component'; +import { TeacherProjectService } from '../../../services/teacherProjectService'; +import { ProjectLocale } from '../../../../../app/domain/projectLocale'; +import { FormsModule } from '@angular/forms'; + +class MockTeacherProjectService { + getLocale() {} + saveProject() {} +} +describe('EditProjectLanguageSettingComponent', () => { + let component: EditProjectLanguageSettingComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [EditProjectLanguageSettingComponent], + imports: [FormsModule, NgSelectModule], + providers: [{ provide: TeacherProjectService, useClass: MockTeacherProjectService }] + }); + fixture = TestBed.createComponent(EditProjectLanguageSettingComponent); + component = fixture.componentInstance; + spyOn(TestBed.inject(TeacherProjectService), 'getLocale').and.returnValue(new ProjectLocale()); + fixture.detectChanges(); + }); + + it('creates', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.ts b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.ts new file mode 100644 index 00000000000..e72456b0aee --- /dev/null +++ b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.ts @@ -0,0 +1,36 @@ +import { Component } from '@angular/core'; +import { Language } from '../../../../../app/domain/language'; +import { TeacherProjectService } from '../../../services/teacherProjectService'; +import { ProjectLocale } from '../../../../../app/domain/projectLocale'; +import { localeToLanguage } from '../../../../../app/domain/localeToLanguage'; + +@Component({ + selector: 'edit-project-language-setting', + templateUrl: './edit-project-language-setting.component.html' +}) +export class EditProjectLanguageSettingComponent { + protected availableLanguages: Language[] = Object.entries( + localeToLanguage + ).map(([locale, language]) => ({ locale: locale, language: language })); + protected defaultLanguage: Language; + private projectLocale: ProjectLocale; + protected supportedLanguages: Language[]; + + constructor(private projectService: TeacherProjectService) {} + + ngOnInit(): void { + this.projectLocale = this.projectService.getLocale(); + this.defaultLanguage = this.projectLocale.getDefaultLanguage(); + this.supportedLanguages = this.projectLocale.getSupportedLanguages(); + } + + protected updateDefaultLanguage(): void { + this.projectLocale.setDefaultLocale(this.defaultLanguage.locale); + this.projectService.saveProject(); + } + + protected updateSupportedLanguages(): void { + this.projectLocale.setSupportedLanguages(this.supportedLanguages); + this.projectService.saveProject(); + } +} diff --git a/src/messages.xlf b/src/messages.xlf index 6a4146c3983..24858601ac4 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -2279,18 +2279,60 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.3 + + German + + src/app/domain/localeToLanguage.ts + 4 + + Japanese src/app/domain/localeToLanguage.ts - 4 + 5 Italian src/app/domain/localeToLanguage.ts - 5 + 6 + + + + Korean + + src/app/domain/localeToLanguage.ts + 7 + + + + Dutch (Netherlands) + + src/app/domain/localeToLanguage.ts + 8 + + + + Vietnamese + + src/app/domain/localeToLanguage.ts + 9 + + + + Chinese (Simplified) + + src/app/domain/localeToLanguage.ts + 10 + + + + Chinese (Traditional) + + src/app/domain/localeToLanguage.ts + 11 @@ -2790,7 +2832,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/app/forgot/teacher/forgot-teacher-password/forgot-teacher-password.component.ts - 91 + 90 @@ -2869,7 +2911,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/app/forgot/teacher/forgot-teacher-password/forgot-teacher-password.component.ts - 81 + 80 @@ -3342,14 +3384,14 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.You have submitted an invalid verification code too many times. For security reasons, we will lock the ability to change your password for 10 minutes. After 10 minutes, you can try again. src/app/forgot/teacher/forgot-teacher-password/forgot-teacher-password.component.ts - 85 + 84 The server has encountered an error and was unable to send you an email. Please try again. If the error continues to occur, please contact us. src/app/forgot/teacher/forgot-teacher-password/forgot-teacher-password.component.ts - 88 + 87 @@ -7392,6 +7434,10 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.src/app/teacher/account/edit-profile/edit-profile.component.html 109 + + src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html + 1 + Language required @@ -12268,6 +12314,20 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.22,24 + + Default language: + + src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html + 2 + + + + Additional languages: + + src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html + 11 + + Back to Teacher Home diff --git a/src/style/styles.scss b/src/style/styles.scss index a9ff04bd1ed..62cae66dc2f 100644 --- a/src/style/styles.scss +++ b/src/style/styles.scss @@ -63,6 +63,7 @@ @import 'themes/dark'; @import 'themes/author'; @import 'themes/monitor'; +@import "~@ng-select/ng-select/themes/material.theme.css"; // TODO: remove/merge after upgrading apps to Angular @import 'themes/apps'; From f235906591937eb8cc08fd6004addc20e9c574a1 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Mon, 4 Dec 2023 14:55:38 -0800 Subject: [PATCH 3/8] Add default language to language chooser dropdown. This used to work when we used to also store default language in supported array. Now, supported array does not support default locale. --- src/app/domain/projectLocale.ts | 4 ++++ ...project-language-chooser.component.spec.ts | 20 ++++++++++++++++--- .../project-language-chooser.component.ts | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/app/domain/projectLocale.ts b/src/app/domain/projectLocale.ts index 7ffdd4fff3f..b61b20ef62d 100644 --- a/src/app/domain/projectLocale.ts +++ b/src/app/domain/projectLocale.ts @@ -9,6 +9,10 @@ export class ProjectLocale { this.locale = locale; } + getAvailableLanguages(): Language[] { + return [this.getDefaultLanguage()].concat(this.getSupportedLanguages()); + } + getDefaultLanguage(): Language { return { language: localeToLanguage[this.locale.default], locale: this.locale.default }; } diff --git a/src/app/student/project-language-chooser/project-language-chooser.component.spec.ts b/src/app/student/project-language-chooser/project-language-chooser.component.spec.ts index 11d6582b8d2..f69b2ad36cd 100644 --- a/src/app/student/project-language-chooser/project-language-chooser.component.spec.ts +++ b/src/app/student/project-language-chooser/project-language-chooser.component.spec.ts @@ -5,11 +5,15 @@ import { StudentTeacherCommonServicesModule } from '../../student-teacher-common import { ProjectService } from '../../../assets/wise5/services/projectService'; import { ProjectLocale } from '../../domain/projectLocale'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { HarnessLoader } from '@angular/cdk/testing'; +import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; +import { MatSelectHarness } from '@angular/material/select/testing'; let projectService: ProjectService; describe('ProjectLanguageChooserComponent', () => { let component: ProjectLanguageChooserComponent; let fixture: ComponentFixture; + let loader: HarnessLoader; beforeEach(async () => { await TestBed.configureTestingModule({ @@ -24,13 +28,23 @@ describe('ProjectLanguageChooserComponent', () => { }); beforeEach(() => { - spyOn(projectService, 'getLocale').and.returnValue(new ProjectLocale()); + spyOn(projectService, 'getLocale').and.returnValue( + new ProjectLocale({ default: 'en_US', supported: ['ja', 'es'] }) + ); fixture = TestBed.createComponent(ProjectLanguageChooserComponent); + loader = TestbedHarnessEnvironment.loader(fixture); component = fixture.componentInstance; fixture.detectChanges(); }); - it('should create', () => { - expect(component).toBeTruthy(); + it('shows available languages', async () => { + const selects = await loader.getAllHarnesses(MatSelectHarness); + const selectComponent = selects[0]; + await selectComponent.open(); + const options = await selectComponent.getOptions(); + expect(options.length).toEqual(3); + expect(await options[0].getText()).toMatch('English'); + expect(await options[1].getText()).toMatch('Japanese'); + expect(await options[2].getText()).toMatch('Spanish'); }); }); diff --git a/src/app/student/project-language-chooser/project-language-chooser.component.ts b/src/app/student/project-language-chooser/project-language-chooser.component.ts index 451d25a2943..617f03e3433 100644 --- a/src/app/student/project-language-chooser/project-language-chooser.component.ts +++ b/src/app/student/project-language-chooser/project-language-chooser.component.ts @@ -24,7 +24,7 @@ export class ProjectLanguageChooserComponent implements OnInit { ngOnInit(): void { const unitLocale = this.projectService.getLocale(); - this.availableLanguages = unitLocale.getSupportedLanguages(); + this.availableLanguages = unitLocale.getAvailableLanguages(); this.selectedLanguage = this.availableLanguages.find((language) => unitLocale.isDefaultLocale(language.locale) ); From 279e6e3b6bfcef6deedd4ca9a8fb12eb75010b39 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Mon, 4 Dec 2023 19:06:56 -0800 Subject: [PATCH 4/8] Setting default locale automatically removes it from available languages option. --- src/app/domain/projectLocale.ts | 3 +++ .../edit-project-language-setting.component.ts | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/app/domain/projectLocale.ts b/src/app/domain/projectLocale.ts index b61b20ef62d..45fdeef26bc 100644 --- a/src/app/domain/projectLocale.ts +++ b/src/app/domain/projectLocale.ts @@ -19,6 +19,9 @@ export class ProjectLocale { setDefaultLocale(locale: string): void { this.locale.default = locale; + this.locale.supported = this.locale.supported.filter( + (supportedLocale) => supportedLocale != locale + ); } getSupportedLanguages(): Language[] { diff --git a/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.ts b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.ts index e72456b0aee..4bd26f05117 100644 --- a/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.ts +++ b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.ts @@ -9,9 +9,7 @@ import { localeToLanguage } from '../../../../../app/domain/localeToLanguage'; templateUrl: './edit-project-language-setting.component.html' }) export class EditProjectLanguageSettingComponent { - protected availableLanguages: Language[] = Object.entries( - localeToLanguage - ).map(([locale, language]) => ({ locale: locale, language: language })); + protected availableLanguages: Language[]; protected defaultLanguage: Language; private projectLocale: ProjectLocale; protected supportedLanguages: Language[]; @@ -19,18 +17,30 @@ export class EditProjectLanguageSettingComponent { constructor(private projectService: TeacherProjectService) {} ngOnInit(): void { + this.updateModel(); + } + + private updateModel(): void { this.projectLocale = this.projectService.getLocale(); this.defaultLanguage = this.projectLocale.getDefaultLanguage(); this.supportedLanguages = this.projectLocale.getSupportedLanguages(); + this.availableLanguages = Object.entries(localeToLanguage) + .map(([locale, language]) => ({ + locale: locale, + language: language + })) + .filter((language) => language.locale != this.defaultLanguage.locale); } protected updateDefaultLanguage(): void { this.projectLocale.setDefaultLocale(this.defaultLanguage.locale); this.projectService.saveProject(); + this.updateModel(); } protected updateSupportedLanguages(): void { this.projectLocale.setSupportedLanguages(this.supportedLanguages); this.projectService.saveProject(); + this.updateModel(); } } From 5a4eecbfa31d4304c055fe28289fbac8e360d430 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Mon, 4 Dec 2023 19:27:56 -0800 Subject: [PATCH 5/8] Save language settings even if project does not have a metadata.locale field. --- src/app/domain/projectLocale.ts | 3 +- .../TeacherProjectServiceSpec.project.json | 1 + .../services/translateProjectService.spec.ts | 4 ++- ...project-language-setting.component.spec.ts | 4 ++- src/assets/wise5/services/projectService.ts | 4 +++ src/messages.xlf | 32 +++++++++---------- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/app/domain/projectLocale.ts b/src/app/domain/projectLocale.ts index 45fdeef26bc..8df6ee9e86f 100644 --- a/src/app/domain/projectLocale.ts +++ b/src/app/domain/projectLocale.ts @@ -1,11 +1,10 @@ import { Language } from './language'; import { localeToLanguage } from './localeToLanguage'; -const defaultProjectLocale = { default: 'en_US', supported: [] }; export class ProjectLocale { private locale: { default: string; supported: string[] }; - constructor(locale: any = defaultProjectLocale) { + constructor(locale: any) { this.locale = locale; } diff --git a/src/app/services/sampleData/curriculum/TeacherProjectServiceSpec.project.json b/src/app/services/sampleData/curriculum/TeacherProjectServiceSpec.project.json index bd80120f958..89021c0d7b9 100644 --- a/src/app/services/sampleData/curriculum/TeacherProjectServiceSpec.project.json +++ b/src/app/services/sampleData/curriculum/TeacherProjectServiceSpec.project.json @@ -1,6 +1,7 @@ { "startGroupId": "group0", "startNodeId": "node1", + "metadata": {}, "nodes": [ { "id": "group0", diff --git a/src/app/services/translateProjectService.spec.ts b/src/app/services/translateProjectService.spec.ts index 648307233d8..2476f22d560 100644 --- a/src/app/services/translateProjectService.spec.ts +++ b/src/app/services/translateProjectService.spec.ts @@ -28,7 +28,9 @@ describe('TranslateProjectService', () => { describe('translate()', () => { describe('has no translations to apply', () => { beforeEach(() => { - spyOn(projectService, 'getLocale').and.returnValue(new ProjectLocale()); + spyOn(projectService, 'getLocale').and.returnValue( + new ProjectLocale({ default: 'en_US', supported: [] }) + ); }); it('should keep original project in tact', () => { service.translate().then(() => { diff --git a/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.spec.ts b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.spec.ts index 801f53853d4..ecd4a4f58a1 100644 --- a/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.spec.ts +++ b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.spec.ts @@ -21,7 +21,9 @@ describe('EditProjectLanguageSettingComponent', () => { }); fixture = TestBed.createComponent(EditProjectLanguageSettingComponent); component = fixture.componentInstance; - spyOn(TestBed.inject(TeacherProjectService), 'getLocale').and.returnValue(new ProjectLocale()); + spyOn(TestBed.inject(TeacherProjectService), 'getLocale').and.returnValue( + new ProjectLocale({ default: 'en_US', supported: [] }) + ); fixture.detectChanges(); }); diff --git a/src/assets/wise5/services/projectService.ts b/src/assets/wise5/services/projectService.ts index b9b436412d3..354013f666d 100644 --- a/src/assets/wise5/services/projectService.ts +++ b/src/assets/wise5/services/projectService.ts @@ -237,6 +237,10 @@ export class ProjectService { instantiateDefaults(): void { this.project.nodes = this.project.nodes ? this.project.nodes : []; this.project.inactiveNodes = this.project.inactiveNodes ? this.project.inactiveNodes : []; + this.project.metadata.locale = this.project.metadata.locale ?? { + default: 'en_US', + supported: [] + }; } private calculateNodeOrderOfProject(): void { diff --git a/src/messages.xlf b/src/messages.xlf index 24858601ac4..3f044624fa9 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -21228,112 +21228,112 @@ If this problem continues, let your teacher know and move on to the next activit Complete <b></b> src/assets/wise5/services/projectService.ts - 1192 + 1196 Visit <b></b> src/assets/wise5/services/projectService.ts - 1198 + 1202 Correctly answer <b></b> src/assets/wise5/services/projectService.ts - 1204 + 1208 Obtain a score of <b></b> on <b></b> src/assets/wise5/services/projectService.ts - 1219 + 1223 You must choose "" on "" src/assets/wise5/services/projectService.ts - 1227 + 1231 Submit <b></b> time on <b></b> src/assets/wise5/services/projectService.ts - 1239 + 1243 Submit <b></b> times on <b></b> src/assets/wise5/services/projectService.ts - 1241 + 1245 Take the branch path from <b></b> to <b></b> src/assets/wise5/services/projectService.ts - 1248 + 1252 Write <b></b> words on <b></b> src/assets/wise5/services/projectService.ts - 1254 + 1258 "" is visible src/assets/wise5/services/projectService.ts - 1260 + 1264 "" is visitable src/assets/wise5/services/projectService.ts - 1266 + 1270 Add <b></b> note on <b></b> src/assets/wise5/services/projectService.ts - 1273 + 1277 Add <b></b> notes on <b></b> src/assets/wise5/services/projectService.ts - 1275 + 1279 You must fill in <b></b> row in the <b>Table</b> on <b></b> src/assets/wise5/services/projectService.ts - 1282 + 1286 You must fill in <b></b> rows in the <b>Table</b> on <b></b> src/assets/wise5/services/projectService.ts - 1284 + 1288 Wait for your teacher to unlock the item src/assets/wise5/services/projectService.ts - 1287 + 1291 From bd4d665de619af2ac8d1ceed98f464b27ab635d9 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Mon, 4 Dec 2023 19:29:49 -0800 Subject: [PATCH 6/8] Fix issue where select language dropdown in the vle was not appearing when there is 1 supported language --- src/app/domain/projectLocale.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/domain/projectLocale.ts b/src/app/domain/projectLocale.ts index 8df6ee9e86f..a6e3846cded 100644 --- a/src/app/domain/projectLocale.ts +++ b/src/app/domain/projectLocale.ts @@ -39,7 +39,7 @@ export class ProjectLocale { } hasTranslations(): boolean { - return this.locale.supported.length > 1; + return this.locale.supported.length > 0; } hasTranslationsToApply(locale: string): boolean { From 679b45b1db5dd06ded3c022d4239895e40f2e465 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Mon, 4 Dec 2023 19:34:58 -0800 Subject: [PATCH 7/8] Alphabetized language choices and changed "Dutch (Netherlands)" => "Dutch" --- src/app/domain/localeToLanguage.ts | 12 ++++----- src/messages.xlf | 40 +++++++++++++++--------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/app/domain/localeToLanguage.ts b/src/app/domain/localeToLanguage.ts index 324bd01856d..c18f05d2bbc 100644 --- a/src/app/domain/localeToLanguage.ts +++ b/src/app/domain/localeToLanguage.ts @@ -1,12 +1,12 @@ export const localeToLanguage: { [locale: string]: string } = { + zh_CN: $localize`Chinese (Simplified)`, + zh_TW: $localize`Chinese (Traditional)`, + nl: $localize`Dutch`, en_US: $localize`English`, - es: $localize`Spanish`, de: $localize`German`, - ja: $localize`Japanese`, it: $localize`Italian`, + ja: $localize`Japanese`, ko: $localize`Korean`, - nl: $localize`Dutch (Netherlands)`, - vi: $localize`Vietnamese`, - zh_CN: $localize`Chinese (Simplified)`, - zh_TW: $localize`Chinese (Traditional)` + es: $localize`Spanish`, + vi: $localize`Vietnamese` }; diff --git a/src/messages.xlf b/src/messages.xlf index 3f044624fa9..a44fe86b8ac 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -2265,71 +2265,71 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.138 - - English + + Chinese (Simplified) src/app/domain/localeToLanguage.ts 2 - - Spanish + + Chinese (Traditional) src/app/domain/localeToLanguage.ts 3 - - German + + Dutch src/app/domain/localeToLanguage.ts 4 - - Japanese + + English src/app/domain/localeToLanguage.ts 5 - - Italian + + German src/app/domain/localeToLanguage.ts 6 - - Korean + + Italian src/app/domain/localeToLanguage.ts 7 - - Dutch (Netherlands) + + Japanese src/app/domain/localeToLanguage.ts 8 - - Vietnamese + + Korean src/app/domain/localeToLanguage.ts 9 - - Chinese (Simplified) + + Spanish src/app/domain/localeToLanguage.ts 10 - - Chinese (Traditional) + + Vietnamese src/app/domain/localeToLanguage.ts 11 From d8dc0174b77382f8377c22c8143c2dbb958facde Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Mon, 4 Dec 2023 19:39:02 -0800 Subject: [PATCH 8/8] Keep available languages select drop down open after add/delete/select --- .../edit-project-language-setting.component.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html index f62584fd5d6..6fe1e62558c 100644 --- a/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html +++ b/src/assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component.html @@ -13,6 +13,7 @@

Language

[items]="availableLanguages" bindLabel="language" [(ngModel)]="supportedLanguages" + [closeOnSelect]="false" [multiple]="true" (change)="updateSupportedLanguages()" >