Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension Manifest Map: localization #2360

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/packages/core/extension-registry/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import type { ManifestGlobalContext } from './global-context.model.js';
import type { ManifestHeaderApp, ManifestHeaderAppButtonKind } from './header-app.model.js';
import type { ManifestHealthCheck } from './health-check.model.js';
import type { ManifestIcons } from './icons.model.js';
import type { ManifestLocalization } from './localization.model.js';
import type { ManifestMenu } from './menu.model.js';
import type { ManifestMenuItem, ManifestMenuItemLinkKind, ManifestMenuItemTreeKind } from './menu-item.model.js';
import type { ManifestPreviewAppProvider } from './preview-app.model.js';
Expand Down Expand Up @@ -67,7 +66,6 @@ export type * from './global-context.model.js';
export type * from './header-app.model.js';
export type * from './health-check.model.js';
export type * from './icons.model.js';
export type * from './localization.model.js';
export type * from './menu-item.model.js';
export type * from './menu.model.js';
export type * from './mfa-login-provider.model.js';
Expand Down Expand Up @@ -127,7 +125,6 @@ export type ManifestTypes =
| ManifestHealthCheck
| ManifestIcons
| ManifestItemStore
| ManifestLocalization
| ManifestMenu
| ManifestMenuItem
| ManifestMenuItemTreeKind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import type { UUISelectEvent } from '@umbraco-cms/backoffice/external/uui';
import { UUIFormControlMixin } from '@umbraco-cms/backoffice/external/uui';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type { ManifestLocalization } from '@umbraco-cms/backoffice/extension-registry';
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import type { ManifestLocalization } from '../../extensions/localization.extension';

Check failure on line 7 in src/packages/core/localization/components/ui-culture-input/ui-culture-input.element.ts

View workflow job for this annotation

GitHub Actions / build

Relative imports should use the ".js" file extension

interface UmbCultureInputOption {
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface MetaLocalization {
* The value is used to describe the language of the translations according to the extension system
* and it will be set as the `lang` attribute on the `<html>` element.
* @see https://en.wikipedia.org/wiki/Language_localisation#Language_tags_and_codes
* @examples ["en-us", "en-gb", "da-dk"]
* @example ["en-us", "en-gb", "da-dk"]
*/
culture: string;

Expand All @@ -25,7 +25,7 @@ export interface MetaLocalization {
* The value is used to describe the direction of the translations according to the extension system
* and it will be set as the `dir` attribute on the `<html>` element. It defaults to `ltr`.
* @see https://en.wikipedia.org/wiki/Right-to-left
* @examples ["ltr"]
* @example ["ltr"]
* @default "ltr"
*/
direction?: 'ltr' | 'rtl';
Expand All @@ -42,3 +42,9 @@ export interface MetaLocalization {
*/
localizations?: UmbLocalizationDictionary;
}

declare global {
interface UmbExtensionManifestMap {
UmbLocalizationExtension: ManifestLocalization;
}
}
1 change: 1 addition & 0 deletions src/packages/core/localization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import './localize-number.element.js';
import './localize-relative-time.element.js';

export * from './registry/localization.registry.js';
export type * from './extensions/localization.extension.js';
export { UmbUiCultureInputElement } from './components/index.js';
2 changes: 1 addition & 1 deletion src/packages/core/localization/localize.element.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UmbLocalizeElement } from './localize.element.js';
import { aTimeout, elementUpdated, expect, fixture, html } from '@open-wc/testing';
import { umbLocalizationRegistry } from '@umbraco-cms/backoffice/localization';
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api';
import { umbLocalizationRegistry } from './registry/localization.registry.js';

const english = {
type: 'localization',
Expand Down
2 changes: 1 addition & 1 deletion src/packages/core/localization/manifests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ManifestLocalization } from '../extension-registry/models/localization.model.js';
import type { ManifestLocalization } from './extensions/localization.extension.js';

export const manifests: Array<ManifestLocalization> = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UmbLocalizationRegistry } from './localization.registry.js';
import { aTimeout, expect } from '@open-wc/testing';
import type { ManifestLocalization } from '@umbraco-cms/backoffice/extension-registry';
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import type { ManifestLocalization } from '../extensions/localization.extension.js';

//#region Localizations
const english: ManifestLocalization = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
UMB_DEFAULT_LOCALIZATION_CULTURE,
} from '@umbraco-cms/backoffice/localization-api';
import { umbLocalizationManager } from '@umbraco-cms/backoffice/localization-api';
import type { ManifestLocalization, UmbBackofficeExtensionRegistry } from '@umbraco-cms/backoffice/extension-registry';
import type { UmbBackofficeExtensionRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { UmbStringState } from '@umbraco-cms/backoffice/observable-api';
import { combineLatest } from '@umbraco-cms/backoffice/external/rxjs';
import { hasDefaultExport, loadManifestPlainJs } from '@umbraco-cms/backoffice/extension-api';
import type { ManifestLocalization } from '../extensions/localization.extension';

Check failure on line 13 in src/packages/core/localization/registry/localization.registry.ts

View workflow job for this annotation

GitHub Actions / build

Relative imports should use the ".js" file extension

/**
*
Expand Down Expand Up @@ -37,6 +38,7 @@

/**
* Get the current registered translations.
* @returns {Map<string, UmbLocalizationSetBase>} Returns the registered translations
*/
get localizations() {
return umbLocalizationManager.localizations;
Expand Down Expand Up @@ -111,7 +113,7 @@

/**
* Load a language from the extension registry.
* @param locale The locale to load.
* @param {string} locale The locale to load.
*/
loadLanguage(locale: string) {
this.#currentLanguage.setValue(locale.toLowerCase());
Expand Down
Loading