blob: 79f95057a056f6e4575bce23778a64a785753523 [file] [log] [blame]
talig8e9c0652017-12-20 14:30:43 +02001import React from 'react';
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +02002import { storiesOf } from '@kadira/storybook';
3import { withKnobs } from '@kadira/storybook-addon-knobs';
talig8e9c0652017-12-20 14:30:43 +02004import i18n from 'nfvo-utils/i18n/i18n.js';
5import i18nJson from 'nfvo-utils/i18n/en.json';
6
7const stories = storiesOf('i18n', module);
8stories.addDecorator(withKnobs);
9
talig8e9c0652017-12-20 14:30:43 +020010i18nJson['added'] = 'this is my test';
11i18nJson['added with {param}'] = 'this is my test with {param}';
12
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020013stories.add('i18n tests', () => {
14 let keys = [
15 'I do not exist',
16 'Delete',
17 'OrchestrationTemplateCandidate/File Structure'
18 ];
19 let translations = [];
20 let i = 0;
21 translations.push(<div id={i++}>KEY: VALUE</div>);
22 keys.forEach(key => {
23 translations.push(
24 <div id={i++}>
25 {key} : {i18n(key)}{' '}
26 </div>
27 );
28 });
29 var param = 'param';
30 translations.push(<div id={i++}>added : {i18n('added')} </div>);
31 translations.push(
32 <div id={i++}>
33 <font color="red">
34 <b>WRONG</b>
35 </font>{' '}
36 - added with ${param} in translation : {i18n(`added with ${param}`)}{' '}
37 </div>
38 );
39 translations.push(
40 <div id={i++}>
41 <font color="green">
42 <b>RIGHT</b>
43 </font>{' '}
44 - added with ${param} and options object{' '}
45 {JSON.stringify({ param: param })}:{' '}
46 {i18n('added with {param}', { param: param })}{' '}
47 </div>
48 );
talig8e9c0652017-12-20 14:30:43 +020049
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020050 return <div>{translations}</div>;
51});