cedar-embeddable-editor 1.0.15 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -0
- package/cedar-embeddable-editor.js +1 -1
- package/package.json +1 -1
- package/assets/i18n-cee/en.json +0 -80
- package/assets/i18n-cee/hu.json +0 -80
package/README.md
CHANGED
|
@@ -137,6 +137,7 @@ There are other optional configuration parameters available for controlling vari
|
|
|
137
137
|
"showHeader": true,
|
|
138
138
|
"showFooter": true,
|
|
139
139
|
|
|
140
|
+
"languageMapPathPrefix": null,
|
|
140
141
|
"defaultLanguage": "en",
|
|
141
142
|
"fallbackLanguage": "en",
|
|
142
143
|
|
|
@@ -244,6 +245,65 @@ nonNullRequiredFieldValueCount: int
|
|
|
244
245
|
isValid: boolean
|
|
245
246
|
```
|
|
246
247
|
|
|
248
|
+
### Language Maps / Translations
|
|
249
|
+
|
|
250
|
+
The application currently has two built-in language maps: `en` and `hu`. If you do not specify any language-related config option, the default `English` map will be used.
|
|
251
|
+
|
|
252
|
+
If you wish to change the language to another built-in one (currently the only other language is `Hungarian`), specify the config like below:
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"defaultLanguage": "hu",
|
|
257
|
+
"fallbackLanguage": "en"
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
You can use external language maps as well. In order to do this, specify a relative path to a folder containing the language file. The file should be named `x.json`, and should have the identical structure of the language map found in the source of the application:
|
|
262
|
+
|
|
263
|
+
https://github.com/metadatacenter/cedar-embeddable-editor/blob/main/src/assets/i18n-cee/en.json
|
|
264
|
+
|
|
265
|
+
In order to use an external language file, specify the config as follows:
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
{
|
|
269
|
+
"languageMapPathPrefix": "/assets/i18n-cee/",
|
|
270
|
+
"defaultLanguage": "de",
|
|
271
|
+
"fallbackLanguage": "en"
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
In the example above we want to use a `German` language file, which is located in the specified directory. Starting the path with `/` makes the path absolute.
|
|
276
|
+
|
|
277
|
+
In our case the `/assets/i18n-cee/de.json` will be loaded if present.
|
|
278
|
+
|
|
279
|
+
If the file is missing, the `/assets/i18n-cee/en.json` will be used.
|
|
280
|
+
|
|
281
|
+
If that file is also missing, the built-in `de` map would be the next. As this does not exist at this moment, the last option, the built-in `en` map will be used.
|
|
282
|
+
|
|
283
|
+
Information about the loading process is logged onto the console with the `CEE TRACE` prefix.
|
|
284
|
+
|
|
285
|
+
### Listening for changes
|
|
286
|
+
|
|
287
|
+
If you need to listen to data changes inside the embeddable editor, you can use the existing `change` DOM events. We added custom events in case of a multi-instance add, copy and delete operations, so you can listen to all the events on the instance.
|
|
288
|
+
|
|
289
|
+
An example in Angular is:
|
|
290
|
+
|
|
291
|
+
- `component.html`:
|
|
292
|
+
```html
|
|
293
|
+
<cedar-embeddable-editor
|
|
294
|
+
[config]="conf"
|
|
295
|
+
[templateObject]="template"
|
|
296
|
+
[instanceObject]="instance"
|
|
297
|
+
(change)="logChange($event)"
|
|
298
|
+
></cedar-embeddable-editor>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
- `component.ts`:
|
|
302
|
+
```typescript
|
|
303
|
+
logChange(event) {
|
|
304
|
+
console.log('CHANGE', event);
|
|
305
|
+
}
|
|
306
|
+
```
|
|
247
307
|
|
|
248
308
|
## Example Applications
|
|
249
309
|
|