@alfresco/adf-core
Version:
101 lines (100 loc) • 3.67 kB
TypeScript
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 { InjectionToken } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { TranslateLoaderService } from './translate-loader.service';
import { UserPreferencesService } from '../common/services/user-preferences.service';
import * as i0 from "@angular/core";
export declare const TRANSLATION_PROVIDER: InjectionToken<unknown>;
export interface TranslationProvider {
name: string;
source: string;
}
/**
* Generate translation provider
*
* @param id Unique identifier
* @param path Path to translation files
* @returns Provider
*/
export declare function provideTranslations(id: string, path: string): {
provide: InjectionToken<unknown>;
multi: boolean;
useValue: {
name: string;
source: string;
};
};
export declare class TranslationService {
translate: TranslateService;
defaultLang: string;
userLang: string;
customLoader: TranslateLoaderService;
constructor(translate: TranslateService, userPreferencesService: UserPreferencesService, providers: TranslationProvider[]);
/**
* Adds a new folder of translation source files.
*
* @param name Name for the translation provider
* @param path Path to the folder
*/
addTranslationFolder(name?: string, path?: string): void;
/**
* Loads a translation file.
*
* @param lang Language code for the language to load
* @param fallback Language code to fall back to if the first one was unavailable
*/
loadTranslation(lang: string, fallback?: string): void;
/**
* Triggers a notification callback when the translation language changes.
*
* @param lang The new language code
*/
onTranslationChanged(lang: string): void;
/**
* Sets the target language for translations.
*
* @param lang Code name for the language
* @returns Translations available for the language
*/
use(lang: string): Observable<any>;
/**
* Gets the translation for the supplied key.
*
* @param key Key to translate
* @param interpolateParams String(s) to be interpolated into the main message
* @returns Translated text
*/
get(key: string | Array<string>, interpolateParams?: any): Observable<string | any>;
/**
* Determines the preferred locale for the current user.
*
* @returns Locale identifier resolved from the browser or the default translation locale
*/
getLocale(): string;
/**
* Directly returns the translation for the supplied key.
*
* @param key Key to translate
* @param interpolateParams String(s) to be interpolated into the main message
* @returns Translated text
*/
instant(key: string | Array<string>, interpolateParams?: any): string | any;
static ɵfac: i0.ɵɵFactoryDeclaration<TranslationService, [null, null, { optional: true; }]>;
static ɵprov: i0.ɵɵInjectableDeclaration<TranslationService>;
}