How to use @opuscapita/i18n - 9 common examples

To help you get started, we’ve selected a few @opuscapita/i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpusCapita / fsm-workflow / packages / editor / src / components / TopForm.spec.js View on Github external
it('renders top form', () => {
    const props = {
      name: 'Invoice workflow',
      onNameChange: sinon.spy()
    };

    const wrapper = mount(, { context: { i18n: new I18nManager() } });
    expect(wrapper).to.exist; // eslint-disable-line no-unused-expressions
    expect(wrapper.contains(FormControl)).to.be.true; // eslint-disable-line no-unused-expressions
    expect(wrapper.find(FormControl).prop('value')).to.equal(props.name);
    expect(wrapper.find(FormControl).prop('onChange')).to.equal(props.onNameChange);
  });
});
github OpusCapita / fsm-workflow / packages / editor / src / components / StatesTable / StatesTable.spec.js View on Github external
import React from 'react';
import { expect } from 'chai';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';
import { mount } from 'enzyme';
import StatesTable from './StatesTable.react';
import { I18nManager } from '@opuscapita/i18n';
import messages from '../../i18n';

const i18n = new I18nManager();
i18n.register('asddass', messages);

Enzyme.configure({ adapter: new Adapter() });

describe('', () => {
  it('renders a table of states', () => {
    const props = {
      states: [
        { name: 'one' },
        { name: 'two' }
      ],
      initialState: 'one',
      finalStates: ['two'],
      onDelete: () => {},
      onEdit: () => {},
      statesInTransitions: []
github OpusCapita / fsm-workflow / packages / editor / src / components / WorkflowEditor / WorkflowEditor.spec.js View on Github external
import Adapter from 'enzyme-adapter-react-15';
import { mount } from 'enzyme';
import sinon from 'sinon';
import { I18nManager } from '@opuscapita/i18n';
import Tabs from 'react-bootstrap/lib/Tabs';
import Tab from 'react-bootstrap/lib/Tab';
import TabContent from 'react-bootstrap/lib/TabContent';
import WorkflowEditor from './WorkflowEditor.react';
import StatesTable from '../StatesTable';
import TransitionsTable from '../TransitionsTable';
import EditorOutput from '../EditorOutput.react';
import TopForm from '../TopForm.react';

Enzyme.configure({ adapter: new Adapter() });

const i18n = new I18nManager();

describe('', () => {
  it('renders editor', () => {
    const props = {
      onSave: sinon.spy(),
      workflow: {
        schema: {
          name: 'invoiceFlow',
          initialState: 'open',
          finalStates: ['approved', 'rejected'],
          transitions: [
            {
              from: 'open',
              to: 'validated',
              event: 'validate'
            },
github OpusCapita / react-showroom-client / client / src / components / DefaultScopeComponent / DefaultScopeComponent.react.js View on Github external
getChildContext() {
    if (!this.context.i18n) {
      this.context.i18n = new I18nManager('en', null, formatPatterns);
    }
    return {
      i18n: this.context.i18n,
      serviceRegistry: serviceName => ({ url: 'http://localhost:3000' })
    };
  }
github OpusCapita / fsm-workflow / packages / editor / src / components / WorkflowEditor / WorkflowEditor.SCOPE.react.js View on Github external
handleChangeLanguage = ({ target: { value } }) => this.setState({ locale: value }, _ => {
    this.i18n = new I18nManager({ locale: value });
    this.i18n.register(`${value}-${Math.random()}`, messages);
    this.forceUpdate()
  });
github OpusCapita / fsm-workflow / packages / editor / src / components / WorkflowEditor / WorkflowEditor.SCOPE.react.js View on Github external
constructor(...args) {
    super(...args);

    this.i18n = new I18nManager();
    this.i18n.register(`fsmWorkflowEditor`, messages);
  }
github OpusCapita / react-dates / src / client / components / DateInputField / DateInputField.react.js View on Github external
validate(dateString, dateFormat) {
    const i18nCompatibleFormat = dateFormat.replace(/D/g, 'd').replace(/Y/g, 'y');
    const dc = new DateConverter(i18nCompatibleFormat);

    try {
      const date = dc.stringToValue(dateString);
      const value = !dateString.length ? null : date;
      this.props.onChange(value);
    } catch (err) {
      this.props.onError(err.message);
    }
  }

@opuscapita/i18n

OpusCapita simple i18n mechanism

Apache-2.0
Latest version published 10 months ago

Package Health Score

53 / 100
Full package analysis

Similar packages