Localized Content: All forms are unique in that there is not an endpoint parameter that displays or administers localized versions of a form. However, localized forms do have an extra attribute, ParentOID that refers to the base version (i.e. English). Therefore, no change in coding is necessary to order or administer a localized instance of a form. You just need to know the FormOID.
How to load a new localized version of a form into the API:
1. Create a localization record in the dbo.Localization table by executing the dbo.loadLocalizedForm.
EXECUTE [dbo].[loadLocalizedForm](
@FormOID uniqueidentifier,
@Description nvarchar(255),
@xml xml,
@locale varchar(255)
)
where @FormOID is the base version of the form (i.e. ParentOID)
@Description is the base version name of the form
@xml xml is the localized elements of the form
@locale is the locale code for the localized form
For the xml localized elements, you can retrieve the English version using the below query,
SELECT Form FROM dbo.Localization WHERE FormOID = @FormOID and locale='en-US'
and update the Description attributes with the translated text.
Below is an abbreviated version of @xml parameter after updating with translated text.
< Elements >
<Element ElementOID="37512B7A-A877-4EC5-B3D7-B49408BCFA83" Description="Alltid" />
<Element ElementOID="E14E9E77-5A73-4E91-AA1D-DFF7D12C23F8" Description="Jag kände utmattad" />
<Element ElementOID="255B0E00-D93A-404F-B43E-995964B4D024" Description="Jag kände uttröttad" />
<Element ElementOID="8399FB1C-507E-4BAF-B381-2A0CA992C8FB" Description="Jag. någon energi" />
<Element ElementOID="D77392F8-6181-44E3-8F0B-FDC58A27302C" Description="Jag kände mig tröt" />
. . .
</Elements>
The ElementOID must match the base form version.
2. Create a duplicate form record in the dbo.Forms2 table using the sql script below.
DECLARE @Description nvarchar(255)
SELECT @Description = {Localized Form name}
DECLARE @FormOID uniqueidentifier
SELECT @FormOID = LocalizationOID FROM dbo.Localization WHERE FormOID= @ParentOID and locale = {locale code for the localized form}
INSERT INTO dbo.Forms2(FormOID, Form, Description)
SELECT @FormOID ,Form, @Description FROM dbo.Forms2 WHERE FormOID = @ParentOID
3. Update the Form field by adding the ParentOID attribute.
<Form Status="" DateFinished="" Engine="SequenceEngine" Name="Spanish PROMIS SF v1.0-Depression 4a" ParentOID="597A9B24-5B5C-487D-9606-451355DC6E3D">
<Items>
<Item ItemDataOID="" FormItemOID="820862DC-FE52-41E6-8B11-1C371C8AACE5" ItemResponseOID="" Response="" ResponseTime="" Position="" Section="1" Order="1" ID="EDDEP04" ItemType="">
<Elements>
. . .
4. Update the Element description with the translated versions by calling [dbo].[translateForm]
EXECUTE [dbo].[translateForm](
@TranslatedFormOID UNIQUEIDENTIFIER,
@EnglishFormOID UNIQUEIDENTIFIER,
@locale varchar(255)
5. Create duplicate form record in the dbo.Calibrations2 table. Assuming that base calibrations will be used.
DECLARE @Description nvarchar(255)
SELECT @Description = {Localized Form name}
DECLARE @FormOID uniqueidentifier
SELECT @FormOID = LocalizationOID FROM dbo.Localization WHERE FormOID= @ParentOID and locale = {locale code for the localized form}
INSERT INTO dbo.Calibrations2(FormOID, Form, Scoring Parameter, Description)
SELECT @FormOID, Form, Scoring Parameter, @Description FROM dbo.Calibrations2 WHERE FormOID = @ParentOID
6. Update the FormItemOIDs and ItemResponseOIDs in the localized form by call the [dbo].[updateFormAttributesOIDs] for the localized form.
EXECUTE [dbo].[updateFormAttributeOIDs](
@FormOID UNIQUEIDENTIFIER
)
7. Register
Engine and Event records.
DECLARE @EngineOID uniqueidentifier
SELECT @EngineOID = EngineOID FROM
dbo.FormEngine WHERE FormOID= {English FormOID}
DECLARE @EventOID uniqueidentifier
SELECT @EventOID = EventOID FROM dbo.FormEvent
WHERE FormOID= {English FormOID}
INSERT INTO dbo.FormEngine(FormOID, EngineOID)
VALUES (@FormOID, @EngineOID) -- @FormOID is the localized FormOID
If the
Parent form has an event (i.e. @EventOID is not null)
INSERT INTO dbo.FormEvent(FormOID, EventOID)
VALUES (@FormOID, @EventOID) -- @FormOID is the localized FormOID