mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 01:06:35 +00:00
Restore getHassTranslationsPre109 (#20597)
* Revert "Remove legacy state translations (#20536)" This reverts commit e376efc57920feab37e322f2276beaa31e17d0c0. * keep
This commit is contained in:
parent
469dbbcccc
commit
0725c7b160
@ -97,3 +97,14 @@ export const getHassTranslations = async (
|
|||||||
});
|
});
|
||||||
return result.resources;
|
return result.resources;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getHassTranslationsPre109 = async (
|
||||||
|
hass: HomeAssistant,
|
||||||
|
language: string
|
||||||
|
): Promise<Record<string, unknown>> => {
|
||||||
|
const result = await hass.callWS<{ resources: Record<string, unknown> }>({
|
||||||
|
type: "frontend/get_translations",
|
||||||
|
language,
|
||||||
|
});
|
||||||
|
return result.resources;
|
||||||
|
};
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { atLeastVersion } from "../common/config/version";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { computeLocalize, LocalizeFunc } from "../common/translations/localize";
|
import { computeLocalize, LocalizeFunc } from "../common/translations/localize";
|
||||||
import {
|
import {
|
||||||
@ -8,6 +9,7 @@ import { debounce } from "../common/util/debounce";
|
|||||||
import {
|
import {
|
||||||
FirstWeekday,
|
FirstWeekday,
|
||||||
getHassTranslations,
|
getHassTranslations,
|
||||||
|
getHassTranslationsPre109,
|
||||||
NumberFormat,
|
NumberFormat,
|
||||||
saveTranslationPreferences,
|
saveTranslationPreferences,
|
||||||
TimeFormat,
|
TimeFormat,
|
||||||
@ -284,6 +286,23 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
|||||||
configFlow?: Parameters<typeof getHassTranslations>[4],
|
configFlow?: Parameters<typeof getHassTranslations>[4],
|
||||||
force = false
|
force = false
|
||||||
): Promise<LocalizeFunc> {
|
): Promise<LocalizeFunc> {
|
||||||
|
if (
|
||||||
|
__BACKWARDS_COMPAT__ &&
|
||||||
|
!atLeastVersion(this.hass!.connection.haVersion, 0, 109)
|
||||||
|
) {
|
||||||
|
if (category !== "state") {
|
||||||
|
return this.hass!.localize;
|
||||||
|
}
|
||||||
|
const resources = await getHassTranslationsPre109(this.hass!, language);
|
||||||
|
|
||||||
|
// Ignore the repsonse if user switched languages before we got response
|
||||||
|
if (this.hass!.language !== language) {
|
||||||
|
return this.hass!.localize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._updateResources(language, resources);
|
||||||
|
}
|
||||||
|
|
||||||
let alreadyLoaded: LoadedTranslationCategory;
|
let alreadyLoaded: LoadedTranslationCategory;
|
||||||
|
|
||||||
if (category in this.__loadedTranslations) {
|
if (category in this.__loadedTranslations) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user