LocalizedAttributeService
from skipcheck_tm1.services import LocalizedAttributeService 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.
french = LocalizedAttributesPatch.builder().locale_id("fr").attributes(AttributesPatch.builder().property("Long Name", "Région Nord").build()).build()
return tm1.localized_attributes.create(AttributeOwner.element("Region", "Region", "North"), french)
Read the translation back:
# Attributes other than Caption come back in model_extra
french = tm1.localized_attributes.get(AttributeOwner.element("Region", "Region", "North"), "fr")
values = (french.attributes.model_extra or {}) if french.attributes is not None else {}
return values.get("Long Name")
The asyncio flavor, skipcheck_tm1.aio, has the same methods to await, on AsyncLocalizedAttributeService.
Members
list | The owner's translations, one per locale. |
get | The translations for a locale, or a Tm1NotFoundError if there are none. |
create | Adds translations for a locale. |
list
list(owner: AttributeOwner, query: ODataQuery | None = None, **options: Any) -> list[LocalizedAttributes]GET …/LocalizedAttributes: the owner's translations, one per locale.
get
get(owner: AttributeOwner, locale: str, query: ODataQuery | None = None, **options: Any) -> LocalizedAttributesGET …/LocalizedAttributes('locale'): the translations for a locale, or a Tm1NotFoundError if there are none.
create
create(owner: AttributeOwner, translations: Any) -> LocalizedAttributesPOST …/LocalizedAttributes: adds translations for a locale.