talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 1 | import React from 'react'; |
| 2 | import {storiesOf, action} from '@kadira/storybook'; |
| 3 | import {text, number} from '@kadira/storybook-addon-knobs'; |
| 4 | import {withKnobs} from '@kadira/storybook-addon-knobs'; |
| 5 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
| 6 | import i18nJson from 'nfvo-utils/i18n/en.json'; |
| 7 | |
| 8 | const stories = storiesOf('i18n', module); |
| 9 | stories.addDecorator(withKnobs); |
| 10 | |
| 11 | |
| 12 | i18nJson['added'] = 'this is my test'; |
| 13 | i18nJson['added with {param}'] = 'this is my test with {param}'; |
| 14 | |
| 15 | stories |
| 16 | .add('i18n tests', () => { |
| 17 | let keys = [ |
| 18 | 'I do not exist', |
| 19 | 'Delete', |
| 20 | 'OrchestrationTemplateCandidate/File Structure' |
| 21 | ]; |
| 22 | let translations = []; |
| 23 | let i=0; |
| 24 | translations.push(<div id={i++}>KEY: VALUE</div>) |
| 25 | keys.forEach((key) => { |
| 26 | translations.push((<div id={i++}>{key} : {i18n(key)} </div>)); |
| 27 | }); |
| 28 | var param = 'param'; |
| 29 | translations.push((<div id={i++}>added : {i18n('added')} </div>)); |
| 30 | translations.push((<div id={i++}><font color="red"><b>WRONG</b></font> - added with ${param} in translation : {i18n(`added with ${param}`)} </div>)); |
| 31 | translations.push((<div id={i++}><font color="green"><b>RIGHT</b></font> - added with ${param} and options object {JSON.stringify({param:param})}: {i18n('added with {param}', {param: param})} </div>)); |
| 32 | |
| 33 | return (<div>{translations}</div>); |
| 34 | }) |
| 35 | ; |