diff --git a/src/lib/export/export.service.ts b/src/lib/export/export.service.ts
index 1ca7ad7..a90b457 100644
--- a/src/lib/export/export.service.ts
+++ b/src/lib/export/export.service.ts
@@ -252,7 +252,7 @@ export class ExportService {
this._exportUtils.exportTag(i18ns, 'i18nString', i18n.value, false, [{
key: 'name',
value: i18n.name ?? '',
- }]);
+ }], true);
});
doc.appendChild(i18ns);
});
diff --git a/src/lib/import/import.service.ts b/src/lib/import/import.service.ts
index a875731..86cb40f 100644
--- a/src/lib/import/import.service.ts
+++ b/src/lib/import/import.service.ts
@@ -676,7 +676,7 @@ export class ImportService {
for (const xmlI18string of Array.from(xmlI18strings)) {
const name = this.importUtils.tagAttribute(xmlI18string, 'name');
try {
- const translation = xmlI18string.innerHTML;
+ const translation = this.importUtils.parseDefinition(xmlI18string);
i18nNode.addI18n(new I18nString(translation, name));
} catch (e) {
result.addError(`Importing i18n string '${name}' failed`, e as Error);
diff --git a/src/test/petriflow.spec.js b/src/test/petriflow.spec.js
index 4f7e953..fcd2bda 100644
--- a/src/test/petriflow.spec.js
+++ b/src/test/petriflow.spec.js
@@ -20,8 +20,8 @@ const {
RoleEventType,
Template,
TransitionEventType,
- TriggerType, PetriNet, DataVariable, Expression, Place, Transition,
- RegularPlaceTransitionArc, DataEventSource, DataEvent, Action,
+ TriggerType, PetriNet, DataVariable, Place, Transition,
+ RegularPlaceTransitionArc, DataEvent, Action,
I18nTranslations, Mapping
} = require('../../dist/petriflow');
const fs = require('fs');
@@ -58,7 +58,7 @@ const MODEL_ROLES_LENGTH = 4;
const MODEL_TRANSITIONS_LENGTH = 13;
const MODEL_PLACES_LENGTH = 12;
const MODEL_ARCS_LENGTH = 17;
-const MODEL_DATA_LENGTH = 24;
+const MODEL_DATA_LENGTH = 25;
const MODEL_USERREFS_LENGTH = 2;
const ROLE_1_ID = 'newRole_1';
const ROLE_2_ID = 'newRole_2';
@@ -71,6 +71,7 @@ const ROLE_1_TITLE_NAME = 'role_1_title';
const TIME_TRIGGER_EXACT = '2021-07-14T08:00:00.000Z';
const TIME_TRIGGER_DELAY = 'PT5D';
const TEST_FILE_PATH = 'src/test/resources/petriflow_test.xml';
+const TEST_HTML= 'test_html_i18n';
describe('Petriflow integration tests', () => {
let importService;
@@ -112,13 +113,17 @@ describe('Petriflow integration tests', () => {
}
}
- function assertI18n(locale, i18ns, model) {
+ function assertI18n(locale, i18ns_equal, i18ns_contain, model) {
const i18nLocale = model.getI18n(locale);
- expect(i18nLocale.getI18ns().length).toEqual(i18ns.length);
- i18ns.forEach(i => {
+ expect(i18nLocale.getI18ns().length).toEqual(i18ns_equal.length + i18ns_contain.length);
+ i18ns_equal.forEach(i => {
expect(i18nLocale.getI18n(i)).not.toBeUndefined();
expect(i18nLocale.getI18n(i).value).toEqual(`${locale.toUpperCase()}_${i}`);
});
+ i18ns_contain.forEach(i => {
+ expect(i18nLocale.getI18n(i)).not.toBeUndefined();
+ expect(i18nLocale.getI18n(i).value).toContain(`${locale.toUpperCase()}_${i}`);
+ });
}
function assertRoleRefLogic(roleRef, perform, delegate, cancel, assign, view) {
@@ -308,6 +313,13 @@ describe('Petriflow integration tests', () => {
const textFieldComponent = textField.component;
expect(textFieldComponent).not.toBeUndefined();
expect(textFieldComponent.name).toEqual('area');
+ const htmlField = model.getData('newVariable_22');
+ expect(htmlField.type).toEqual(DataType.TEXT);
+ expect(htmlField.title.value).toEqual('HTMLTextArea init translation with HTML');
+ expect(htmlField.init).not.toBeUndefined();
+ expect(htmlField.init.name).toEqual(TEST_HTML);
+ expect(htmlField.component.name).toEqual('htmltextarea');
+
const enumerationField = model.getData('newVariable_3');
expect(enumerationField).not.toBeUndefined();
expect(enumerationField.options.length).toEqual(3);
@@ -461,8 +473,11 @@ describe('Petriflow integration tests', () => {
'newVariable_19_name',
'case_create_message'
];
- assertI18n('uk', i18ns, model);
- assertI18n('de', i18ns, model);
+ const i18ns_contain = [
+ TEST_HTML
+ ];
+ assertI18n('uk', i18ns, i18ns_contain, model);
+ assertI18n('de', i18ns, i18ns_contain, model);
log('Model i18n correct');
// TODO: mapping?
diff --git a/src/test/resources/petriflow_test.xml b/src/test/resources/petriflow_test.xml
index b3b960e..c22781c 100644
--- a/src/test/resources/petriflow_test.xml
+++ b/src/test/resources/petriflow_test.xml
@@ -506,58 +506,256 @@
newVariable_21
- i18n no translation
+ i18n init translation
newVariable_21 name value
+
+ newVariable_22
+ HTMLTextArea init translation with HTML
+ Nadpis]]>
+
+ htmltextarea
+
+
- UK_title
- duplicate title
- UK_p1_label
- UK_t1_label
- UK_role_1_title
- UK_role_2_title
- UK_role_3_title
- UK_role_4_title
- UK_newVariable_2_title
- UK_newVariable_2_placeholder
- UK_newVariable_2_desc
- UK_newVariable_2_valid_email
- UK_t1_assign_message
- UK_t1_assign_title
- UK_t5_datagroup
- UK_newVariable_3_value1
- UK_newVariable_3_value2
- UK_newVariable_3_value3
- UK_newVariable_4_option_1
- UK_newVariable_4_option_2
- UK_newVariable_4_option_3
- UK_newVariable_19_name
- UK_case_create_message
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UK_test_html_i18n
+ ]]>
+
- DE_title
- DE_p1_label
- DE_t1_label
- DE_role_1_title
- DE_role_2_title
- DE_role_3_title
- DE_role_4_title
- DE_newVariable_2_title
- DE_newVariable_2_placeholder
- DE_newVariable_2_desc
- DE_newVariable_2_valid_email
- DE_t1_assign_message
- DE_t1_assign_title
- DE_t5_datagroup
- DE_newVariable_3_value1
- DE_newVariable_3_value2
- DE_newVariable_3_value3
- DE_newVariable_4_option_1
- DE_newVariable_4_option_2
- DE_newVariable_4_option_3
- DE_newVariable_19_name
- DE_case_create_message
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DE_test_html_i18n
+ ]]>
+