LocalizedAttributeService
import { LocalizedAttributeService } from "@skipcheck/tm1-client"; Translated attribute values: an AttributeOwner's LocalizedAttributes,
one per locale, keyed by locale ID (fr, de-CH). The values are in
Attributes: Caption, and every other attribute in its
dynamicProperties (set with AttributesPatch.Builder.property).
Only attributes the owner's kind has can be translated (see AttributeService):
Caption too, once it's defined. A member's translations are its element's, and
read only: write them through AttributeOwner.element.
TM1 (11.8) creates a locale's translations once and reads them, and that's all: it
supports no PATCH or DELETE on them and refuses to create a locale twice. Changing or
removing translations goes through the }Localized…Attributes control
cubes, as cell writes.
Translate an element's attribute into French:
// The French for an element's Long Name, an attribute its hierarchy has. A locale's
// translations are created once: TM1 can't change them here.
const french = LocalizedAttributesPatch.builder().localeID("fr").attributes(AttributesPatch.builder().property("Long Name", "Région Nord").build()).build();
return tm1.localizedAttributes.create(AttributeOwner.element("Region", "Region", "North"), french);
Read the translation back:
// Attributes are read by their own names, beside Caption
const french = await tm1.localizedAttributes.get(AttributeOwner.element("Region", "Region", "North"), "fr");
const longName = french.Attributes?.["Long Name"];
return typeof longName === "string" ? longName : undefined;
Members
list | GET …/LocalizedAttributes, streamed. |
get | The translations for the locale (such as fr), or a Tm1NotFoundException if there are none. |
create | Adds translations for a locale, its LocaleID and the translated Attributes; returns them as created. |
list
list(owner: AttributeOwner, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<LocalizedAttributes>GET …/LocalizedAttributes, streamed: the owner's translations, one per locale.
get
get(owner: AttributeOwner, locale: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<LocalizedAttributes>GET …/LocalizedAttributes('locale'): the translations for the locale (such as fr), or a Tm1NotFoundException if there are none.
create
create(owner: AttributeOwner, translations: LocalizedAttributesPatch, options?: Tm1CallOptions): Promise<LocalizedAttributes>POST …/LocalizedAttributes: adds translations for a locale, its LocaleID and the translated Attributes; returns them as created.