Fully localize all remaining strings.
This commit is contained in:
+26
-22
@@ -69,8 +69,8 @@ console.info(
|
|||||||
(window as any).customCards = (window as any).customCards || [];
|
(window as any).customCards = (window as any).customCards || [];
|
||||||
(window as any).customCards.push({
|
(window as any).customCards.push({
|
||||||
type: 'frigate-card',
|
type: 'frigate-card',
|
||||||
name: 'Frigate Card',
|
name: localize('common.frigate_card'),
|
||||||
description: 'A lovelace card for use with Frigate',
|
description: localize('common.frigate_card_description'),
|
||||||
});
|
});
|
||||||
|
|
||||||
type FrigateCardMenuCallback = (name: string) => any;
|
type FrigateCardMenuCallback = (name: string) => any;
|
||||||
@@ -307,31 +307,34 @@ export class FrigateCard extends LitElement {
|
|||||||
const buttons: Map<string, MenuButton> = new Map();
|
const buttons: Map<string, MenuButton> = new Map();
|
||||||
|
|
||||||
if (this.config.menu_buttons?.frigate ?? true) {
|
if (this.config.menu_buttons?.frigate ?? true) {
|
||||||
buttons.set('frigate', { description: 'Frigate Menu' });
|
buttons.set('frigate', { description: localize('menu.frigate') });
|
||||||
}
|
}
|
||||||
if (this.config.menu_buttons?.live ?? true) {
|
if (this.config.menu_buttons?.live ?? true) {
|
||||||
buttons.set('live', {
|
buttons.set('live', {
|
||||||
icon: 'mdi:cctv',
|
icon: 'mdi:cctv',
|
||||||
description: 'View Live',
|
description: localize('menu.live'),
|
||||||
emphasize: this._view.is('live'),
|
emphasize: this._view.is('live'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (this.config.menu_buttons?.clips ?? true) {
|
if (this.config.menu_buttons?.clips ?? true) {
|
||||||
buttons.set('clips', {
|
buttons.set('clips', {
|
||||||
icon: 'mdi:filmstrip',
|
icon: 'mdi:filmstrip',
|
||||||
description: 'View Clips',
|
description: localize('menu.clips'),
|
||||||
emphasize: this._view.is('clips'),
|
emphasize: this._view.is('clips'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (this.config.menu_buttons?.snapshots ?? true) {
|
if (this.config.menu_buttons?.snapshots ?? true) {
|
||||||
buttons.set('snapshots', {
|
buttons.set('snapshots', {
|
||||||
icon: 'mdi:camera',
|
icon: 'mdi:camera',
|
||||||
description: 'View Snapshots',
|
description: localize('menu.snapshots'),
|
||||||
emphasize: this._view.is('snapshots'),
|
emphasize: this._view.is('snapshots'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ((this.config.menu_buttons?.frigate_ui ?? true) && this.config.frigate_url) {
|
if ((this.config.menu_buttons?.frigate_ui ?? true) && this.config.frigate_url) {
|
||||||
buttons.set('frigate_ui', { icon: 'mdi:web', description: 'View Frigate UI' });
|
buttons.set('frigate_ui', {
|
||||||
|
icon: 'mdi:web',
|
||||||
|
description: localize('menu.frigate_ui'),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const entities = this.config.entities || [];
|
const entities = this.config.entities || [];
|
||||||
for (let i = 0; this._hass && i < entities.length; i++) {
|
for (let i = 0; this._hass && i < entities.length; i++) {
|
||||||
@@ -357,13 +360,13 @@ export class FrigateCard extends LitElement {
|
|||||||
// Set the object configuration.
|
// Set the object configuration.
|
||||||
public setConfig(inputConfig: FrigateCardConfig): void {
|
public setConfig(inputConfig: FrigateCardConfig): void {
|
||||||
if (!inputConfig) {
|
if (!inputConfig) {
|
||||||
throw new Error(localize('common.invalid_configuration:'));
|
throw new Error(localize('error.invalid_configuration:'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseResult = frigateCardConfigSchema.safeParse(inputConfig);
|
const parseResult = frigateCardConfigSchema.safeParse(inputConfig);
|
||||||
if (!parseResult.success) {
|
if (!parseResult.success) {
|
||||||
const keys = this._getParseErrorKeys(parseResult.error);
|
const keys = this._getParseErrorKeys(parseResult.error);
|
||||||
throw new Error(localize('common.invalid_configuration') + ': ' + keys.join(', '));
|
throw new Error(localize('error.invalid_configuration') + ': ' + keys.join(', '));
|
||||||
}
|
}
|
||||||
const config = parseResult.data;
|
const config = parseResult.data;
|
||||||
|
|
||||||
@@ -376,7 +379,7 @@ export class FrigateCard extends LitElement {
|
|||||||
if (config.camera_entity.includes('.')) {
|
if (config.camera_entity.includes('.')) {
|
||||||
config.frigate_camera_name = config.camera_entity.split('.', 2)[1];
|
config.frigate_camera_name = config.camera_entity.split('.', 2)[1];
|
||||||
} else {
|
} else {
|
||||||
throw new Error(localize('common.invalid_configuration') + ': camera_entity');
|
throw new Error(localize('error.invalid_configuration') + ': camera_entity');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +392,7 @@ export class FrigateCard extends LitElement {
|
|||||||
webrtc.hass = this._hass;
|
webrtc.hass = this._hass;
|
||||||
this._webrtcElement = webrtc;
|
this._webrtcElement = webrtc;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(localize('common.missing_webrtc'));
|
throw new Error(localize('error.missing_webrtc'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,7 +451,7 @@ export class FrigateCard extends LitElement {
|
|||||||
const response = await this._hass.callWS<T>(request);
|
const response = await this._hass.callWS<T>(request);
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
const error_message = `Received empty response from Home Assistant for request ${JSON.stringify(
|
const error_message = `${localize('error.empty_response')}: ${JSON.stringify(
|
||||||
request,
|
request,
|
||||||
)}`;
|
)}`;
|
||||||
console.warn(error_message);
|
console.warn(error_message);
|
||||||
@@ -458,9 +461,9 @@ export class FrigateCard extends LitElement {
|
|||||||
if (!parseResult.success) {
|
if (!parseResult.success) {
|
||||||
const keys = this._getParseErrorKeys(parseResult.error);
|
const keys = this._getParseErrorKeys(parseResult.error);
|
||||||
const error_message =
|
const error_message =
|
||||||
`Received invalid response from Home Assistant for request ${JSON.stringify(
|
`${localize('error.invalid_response')}: ${JSON.stringify(request)}. ` +
|
||||||
request,
|
localize('error.invalid_keys') +
|
||||||
)}, ` + `invalid keys were '${keys}'`;
|
`: '${keys}'`;
|
||||||
console.warn(error_message);
|
console.warn(error_message);
|
||||||
throw new Error(error_message);
|
throw new Error(error_message);
|
||||||
}
|
}
|
||||||
@@ -533,9 +536,8 @@ export class FrigateCard extends LitElement {
|
|||||||
protected _renderError(error: string): TemplateResult {
|
protected _renderError(error: string): TemplateResult {
|
||||||
return this._renderAttentionIcon(
|
return this._renderAttentionIcon(
|
||||||
'mdi:alert-circle',
|
'mdi:alert-circle',
|
||||||
html`${
|
html`${error ? `${error}.` : `${localize('error.unknown_error')}.`}
|
||||||
error ? `${error} .` : `Unknown error .`
|
<a href="${URL_TROUBLESHOOTING}">${localize('error.troubleshooting')}</a>.`,
|
||||||
}Check <a href="${URL_TROUBLESHOOTING}">troubleshooting</a></span>.`,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,7 +557,9 @@ export class FrigateCard extends LitElement {
|
|||||||
if (this._getFirstTrueMediaChildIndex(parent) == null) {
|
if (this._getFirstTrueMediaChildIndex(parent) == null) {
|
||||||
return this._renderAttentionIcon(
|
return this._renderAttentionIcon(
|
||||||
this._view.is('clips') ? 'mdi:filmstrip-off' : 'mdi:camera-off',
|
this._view.is('clips') ? 'mdi:filmstrip-off' : 'mdi:camera-off',
|
||||||
this._view.is('clips') ? 'No clips' : 'No snapshots',
|
this._view.is('clips')
|
||||||
|
? localize('common.no_clips')
|
||||||
|
: localize('common.no_snapshots'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -771,7 +775,7 @@ export class FrigateCard extends LitElement {
|
|||||||
if (!parent || !parent.children || childIndex == null) {
|
if (!parent || !parent.children || childIndex == null) {
|
||||||
return this._renderAttentionIcon(
|
return this._renderAttentionIcon(
|
||||||
this._view.is('clip') ? 'mdi:filmstrip-off' : 'mdi:camera-off',
|
this._view.is('clip') ? 'mdi:filmstrip-off' : 'mdi:camera-off',
|
||||||
this._view.is('clip') ? 'No recent clip' : 'No recent snapshots',
|
this._view.is('clip') ? localize('common.no_clip') : localize('common.no_snapshot'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
mediaToRender = parent.children[childIndex];
|
mediaToRender = parent.children[childIndex];
|
||||||
@@ -786,7 +790,7 @@ export class FrigateCard extends LitElement {
|
|||||||
const resolvedMedia = await this._resolveMedia(mediaToRender);
|
const resolvedMedia = await this._resolveMedia(mediaToRender);
|
||||||
if (!mediaToRender || !resolvedMedia) {
|
if (!mediaToRender || !resolvedMedia) {
|
||||||
// Home Assistant could not resolve media item.
|
// Home Assistant could not resolve media item.
|
||||||
return this._renderError('Could not resolve clip URL');
|
return this._renderError(localize('error.could_not_resolve'));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._mediaBeingShown = {
|
this._mediaBeingShown = {
|
||||||
@@ -922,7 +926,7 @@ export class FrigateCard extends LitElement {
|
|||||||
// is always rendered (but sometimes hidden).
|
// is always rendered (but sometimes hidden).
|
||||||
protected _renderLiveViewer(): TemplateResult {
|
protected _renderLiveViewer(): TemplateResult {
|
||||||
if (!this._hass || !(this.config.camera_entity in this._hass.states)) {
|
if (!this._hass || !(this.config.camera_entity in this._hass.states)) {
|
||||||
return this._renderAttentionIcon('mdi:camera-off', 'No live camera');
|
return this._renderAttentionIcon('mdi:camera-off', localize('error.no_live_camera'));
|
||||||
}
|
}
|
||||||
if (this._webrtcElement) {
|
if (this._webrtcElement) {
|
||||||
return html`${this._webrtcElement}`;
|
return html`${this._webrtcElement}`;
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
{
|
{
|
||||||
"common": {
|
"common": {
|
||||||
"version": "Version",
|
"version": "Version",
|
||||||
"invalid_configuration": "Invalid configuration",
|
|
||||||
"missing_webrtc": "WebRTC component not found",
|
|
||||||
"show_warning": "Show Warning",
|
"show_warning": "Show Warning",
|
||||||
"show_error": "Show Error"
|
"show_error": "Show Error",
|
||||||
|
"frigate_card": "Frigate Card",
|
||||||
|
"frigate_card_description": "A lovelace card for use with Frigate",
|
||||||
|
"no_snapshots": "No snapshots",
|
||||||
|
"no_clips": "No clips",
|
||||||
|
"no_snapshot": "No recent snapshot",
|
||||||
|
"no_clip": "No recent clip"
|
||||||
},
|
},
|
||||||
"editor": {
|
"editor": {
|
||||||
"required": "Required",
|
"required": "Required",
|
||||||
@@ -31,7 +35,7 @@
|
|||||||
"live_provider": "Live view provider (Optional)"
|
"live_provider": "Live view provider (Optional)"
|
||||||
},
|
},
|
||||||
"menu": {
|
"menu": {
|
||||||
"frigate": "Frigate",
|
"frigate": "Frigate Menu / Default View",
|
||||||
"live": "Live View",
|
"live": "Live View",
|
||||||
"clips": "Clips Gallery",
|
"clips": "Clips Gallery",
|
||||||
"snapshots": "Snapshots Gallery",
|
"snapshots": "Snapshots Gallery",
|
||||||
@@ -57,5 +61,16 @@
|
|||||||
},
|
},
|
||||||
"webrtc": {
|
"webrtc": {
|
||||||
"entity": "WebRTC Camera Entity (To use with WebRTC Live Provider)"
|
"entity": "WebRTC Camera Entity (To use with WebRTC Live Provider)"
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"empty_response": "Received empty response from Home Assistant for request",
|
||||||
|
"invalid_response": "Received invalid response from Home Assistant for request",
|
||||||
|
"invalid_keys": "Invalid keys",
|
||||||
|
"unknown": "Unknown error",
|
||||||
|
"troubleshooting": "Check troubleshooting",
|
||||||
|
"could_not_resolve": "Could not resolve media URL",
|
||||||
|
"no_live_camera": "No live camera",
|
||||||
|
"invalid_configuration": "Invalid configuration",
|
||||||
|
"missing_webrtc": "WebRTC component not found"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user