mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-1706] Translate ADF i18n strings into all supported languages (#2490)
* ALL LANGUAGES: This includes all ADF UI files localised into 10 languages as indicated in JIRA ADF-1706: Translate ADF i18n strings into all supported languages * ITALIAN: Small amends to Italian strings as part of previous commit to complete ADF-1706 * Add multilanguages * Load the languages from the app config file * Fix it json * Simplify the adf menu languages * Removed unused code * Basic documentation * Fix unit test
This commit is contained in:
committed by
Eugenio Romano
parent
1cafaa11f1
commit
ed36d08344
@@ -125,6 +125,7 @@ import {
|
||||
InfoDrawerTitleDirective
|
||||
} from './src/components/info-drawer/info-drawer-layout.component';
|
||||
import { InfoDrawerComponent, InfoDrawerTabComponent } from './src/components/info-drawer/info-drawer.component';
|
||||
import { LanguageMenuComponent } from './src/components/language-menu/language-menu.component';
|
||||
import { NodePermissionDirective } from './src/directives/node-permission.directive';
|
||||
import { NodeRestoreDirective } from './src/directives/node-restore.directive';
|
||||
import { UploadDirective } from './src/directives/upload.directive';
|
||||
@@ -276,6 +277,7 @@ export function createTranslateLoader(http: Http, logService: LogService) {
|
||||
InfoDrawerTitleDirective,
|
||||
InfoDrawerButtonsDirective,
|
||||
InfoDrawerContentDirective,
|
||||
LanguageMenuComponent,
|
||||
CreateFolderDialogComponent,
|
||||
DownloadZipDialogComponent,
|
||||
InfinitePaginationComponent,
|
||||
@@ -325,6 +327,7 @@ export function createTranslateLoader(http: Http, logService: LogService) {
|
||||
InfoDrawerButtonsDirective,
|
||||
InfoDrawerContentDirective,
|
||||
InfinitePaginationComponent,
|
||||
LanguageMenuComponent,
|
||||
PaginationComponent
|
||||
],
|
||||
entryComponents: [
|
||||
|
@@ -0,0 +1,28 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
export class TranslationMock {
|
||||
|
||||
get(key: string|Array<string>, interpolateParams?: Object): Observable<string|any> {
|
||||
return Observable.of(key);
|
||||
}
|
||||
|
||||
addTranslationFolder() {
|
||||
}
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { HttpModule } from '@angular/http';
|
||||
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import { providers } from '../../../index';
|
||||
import { MaterialModule } from '../../material.module';
|
||||
import { AppConfigService } from '../../services/app-config.service';
|
||||
import { AlfrescoTranslateLoader } from '../../services/translate-loader.service';
|
||||
import { UserPreferencesService } from '../../services/user-preferences.service';
|
||||
|
||||
import { LanguageMenuComponent } from './language-menu.component';
|
||||
|
||||
describe('LanguageMenuComponent', () => {
|
||||
|
||||
let fixture: ComponentFixture<LanguageMenuComponent>;
|
||||
let component: LanguageMenuComponent;
|
||||
let appConfig: AppConfigService;
|
||||
let translate: TranslateService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
MaterialModule,
|
||||
HttpModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: AlfrescoTranslateLoader
|
||||
}
|
||||
})
|
||||
],
|
||||
declarations: [
|
||||
LanguageMenuComponent
|
||||
],
|
||||
providers: [
|
||||
...providers(),
|
||||
AppConfigService,
|
||||
UserPreferencesService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LanguageMenuComponent);
|
||||
component = fixture.componentInstance;
|
||||
appConfig = TestBed.get(AppConfigService);
|
||||
translate = TestBed.get(TranslateService);
|
||||
});
|
||||
|
||||
it('should have the default language', () => {
|
||||
fixture.detectChanges();
|
||||
expect(component.languages).toEqual([{ key: 'en', label: 'English'}]);
|
||||
});
|
||||
|
||||
it('should fetch the languages from the app config if present', () => {
|
||||
appConfig.config.languages = [
|
||||
{
|
||||
key: 'fake-key-1',
|
||||
label: 'fake-label-1'
|
||||
},
|
||||
{
|
||||
key: 'fake-key-2',
|
||||
label: 'fake-label-2'
|
||||
}
|
||||
];
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.languages).toEqual([
|
||||
{
|
||||
key: 'fake-key-1',
|
||||
label: 'fake-label-1'
|
||||
},
|
||||
{
|
||||
key: 'fake-key-2',
|
||||
label: 'fake-label-2'
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
@@ -0,0 +1,50 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { AppConfigService } from '../../services/app-config.service';
|
||||
import { UserPreferencesService } from '../../services/user-preferences.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-lanugage-menu',
|
||||
template: `
|
||||
<button mat-menu-item *ngFor="let language of languages" (click)="changeLanguage(language.key)">{{language.label}}</button>
|
||||
`
|
||||
})
|
||||
export class LanguageMenuComponent implements OnInit {
|
||||
|
||||
languages: Array<any> = [
|
||||
{ key: 'en', label: 'English'}
|
||||
];
|
||||
|
||||
constructor(
|
||||
private appConfig: AppConfigService,
|
||||
private userPreference: UserPreferencesService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
const languagesCongifApp = this.appConfig.get<Array<any>>(AppConfigService.APP_CONFIG_LANGUAGES_KEY);
|
||||
if (languagesCongifApp) {
|
||||
this.languages = languagesCongifApp;
|
||||
}
|
||||
}
|
||||
|
||||
changeLanguage(lang: string) {
|
||||
this.userPreference.locale = lang;
|
||||
}
|
||||
|
||||
}
|
10
ng2-components/ng2-alfresco-core/src/i18n/de.json
Normal file
10
ng2-components/ng2-alfresco-core/src/i18n/de.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"CORE": {
|
||||
"PAGINATION": {
|
||||
"ITEMS_RANGE": "Angezeigt werden {{ range }} von {{ total }}",
|
||||
"ITEMS_PER_PAGE": "Elemente pro Seite",
|
||||
"CURRENT_PAGE": "Seite {{ number }}",
|
||||
"TOTAL_PAGES": "von {{ total }}"
|
||||
}
|
||||
}
|
||||
}
|
10
ng2-components/ng2-alfresco-core/src/i18n/es.json
Normal file
10
ng2-components/ng2-alfresco-core/src/i18n/es.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"CORE": {
|
||||
"PAGINATION": {
|
||||
"ITEMS_RANGE": "Mostrando {{ range }} de {{ total }}",
|
||||
"ITEMS_PER_PAGE": "Elementos por página",
|
||||
"CURRENT_PAGE": "Página {{ number }}",
|
||||
"TOTAL_PAGES": "de {{ total }}"
|
||||
}
|
||||
}
|
||||
}
|
10
ng2-components/ng2-alfresco-core/src/i18n/fr.json
Normal file
10
ng2-components/ng2-alfresco-core/src/i18n/fr.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"CORE": {
|
||||
"PAGINATION": {
|
||||
"ITEMS_RANGE": "Affichage de {{ range }} sur {{ total }}",
|
||||
"ITEMS_PER_PAGE": "Éléments par page",
|
||||
"CURRENT_PAGE": "Page {{ number }}",
|
||||
"TOTAL_PAGES": "sur {{ total }}"
|
||||
}
|
||||
}
|
||||
}
|
10
ng2-components/ng2-alfresco-core/src/i18n/it.json
Normal file
10
ng2-components/ng2-alfresco-core/src/i18n/it.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"CORE": {
|
||||
"PAGINATION": {
|
||||
"ITEMS_RANGE": "Visualizzazione di {{ range }} su {{ total }}",
|
||||
"ITEMS_PER_PAGE": "Elementi per pagina",
|
||||
"CURRENT_PAGE": "Pagina {{ number }}",
|
||||
"TOTAL_PAGES": "di {{ total }}"
|
||||
}
|
||||
}
|
||||
}
|
10
ng2-components/ng2-alfresco-core/src/i18n/ja.json
Normal file
10
ng2-components/ng2-alfresco-core/src/i18n/ja.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"CORE": {
|
||||
"PAGINATION": {
|
||||
"ITEMS_RANGE": "表示中: {{ range }} / {{ total }} 件",
|
||||
"ITEMS_PER_PAGE": "1 ページのアイテム数",
|
||||
"CURRENT_PAGE": "ページ: {{ number }}",
|
||||
"TOTAL_PAGES": "/ {{ total }}"
|
||||
}
|
||||
}
|
||||
}
|
10
ng2-components/ng2-alfresco-core/src/i18n/nb.json
Normal file
10
ng2-components/ng2-alfresco-core/src/i18n/nb.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"CORE": {
|
||||
"PAGINATION": {
|
||||
"ITEMS_RANGE": "Vis {{ range }} av {{ total }}",
|
||||
"ITEMS_PER_PAGE": "Elementer per side",
|
||||
"CURRENT_PAGE": "Side {{ number }}",
|
||||
"TOTAL_PAGES": "av {{ total }}"
|
||||
}
|
||||
}
|
||||
}
|
10
ng2-components/ng2-alfresco-core/src/i18n/nl.json
Normal file
10
ng2-components/ng2-alfresco-core/src/i18n/nl.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"CORE": {
|
||||
"PAGINATION": {
|
||||
"ITEMS_RANGE": "{{ range }} van {{ total }} wordt weergegeven",
|
||||
"ITEMS_PER_PAGE": "Items per pagina",
|
||||
"CURRENT_PAGE": "Pagina {{ number }}",
|
||||
"TOTAL_PAGES": "van {{ total }}"
|
||||
}
|
||||
}
|
||||
}
|
10
ng2-components/ng2-alfresco-core/src/i18n/pt-BR.json
Normal file
10
ng2-components/ng2-alfresco-core/src/i18n/pt-BR.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"CORE": {
|
||||
"PAGINATION": {
|
||||
"ITEMS_RANGE": "Mostrando {{ range }} de {{ total }}",
|
||||
"ITEMS_PER_PAGE": "Itens por página",
|
||||
"CURRENT_PAGE": "Página {{ number }}",
|
||||
"TOTAL_PAGES": "de {{ total }}"
|
||||
}
|
||||
}
|
||||
}
|
10
ng2-components/ng2-alfresco-core/src/i18n/ru.json
Normal file
10
ng2-components/ng2-alfresco-core/src/i18n/ru.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"CORE": {
|
||||
"PAGINATION": {
|
||||
"ITEMS_RANGE": "Отображается {{ range }} из {{ total }}",
|
||||
"ITEMS_PER_PAGE": "Элементов на странице",
|
||||
"CURRENT_PAGE": "Страница {{ number }}",
|
||||
"TOTAL_PAGES": "из {{ total }}"
|
||||
}
|
||||
}
|
||||
}
|
10
ng2-components/ng2-alfresco-core/src/i18n/zh-CN.json
Normal file
10
ng2-components/ng2-alfresco-core/src/i18n/zh-CN.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"CORE": {
|
||||
"PAGINATION": {
|
||||
"ITEMS_RANGE": "显示 {{range}}/{{total}}",
|
||||
"ITEMS_PER_PAGE": "每页的项目",
|
||||
"CURRENT_PAGE": "第 {{number}} 页",
|
||||
"TOTAL_PAGES": "/共 {{total}} 页"
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,6 +22,8 @@ import { ObjectUtils } from '../utils/object-utils';
|
||||
@Injectable()
|
||||
export class AppConfigService {
|
||||
|
||||
static APP_CONFIG_LANGUAGES_KEY = 'languages';
|
||||
|
||||
config: any = {
|
||||
application: {
|
||||
name: 'Alfresco ADF Application'
|
||||
|
Reference in New Issue
Block a user