Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Update to API changes from axI18n #149

Closed
jpommerening opened this issue Mar 6, 2017 · 2 comments
Closed

Update to API changes from axI18n #149

jpommerening opened this issue Mar 6, 2017 · 2 comments
Assignees
Milestone

Comments

@jpommerening
Copy link
Member

Here's an API change in Laxar that the local mocks hid from the tests: i18n.localizeRelaxed is gone. There is no API to supply a language tag when localizing either.

See LaxarJS/laxar#429

@jpommerening
Copy link
Member Author

jpommerening commented Mar 8, 2017

BREAKING CHANGE

New API!

  • ui.i18n has been removed
  • ui.options( [opts] ) provides default formatting and parsing options of the ui instance
  • a localized ui object can be created with ui.localized( i18n )

Previously, users had to use ui.i18n.momentFormatForLanguageTag and ui.i18n.numberFormatForLanguageTag and then manually construct formatting options (like ax-input-control does). These options then could be used to create formatters and parsers with ui.formatter.create() and ui.parser.create().
Instead, UiKit now can provide formatters and parsers for a given axI18n incarnation directly, without the user having to build the options object manually. Options can still be overriden just like before. Also, a copy of the "current" options can be requested with the new options() method.

Here's a formal description of the new API in Typescript notation.

class AxUikitBaseOptions {
   groupingSeparator?: string,
   decimalSeparator?: string,
   dateFormat?: string,
   timeFormat?: string
}

class AxUikitFormatterOptions extends AxUikitBaseOptions {
   decimalPlaces?: integer,
   decimalTruncation?: 'FIXED' | 'BOUNDED' | 'NONE'
}

class AxUikitParserOptions extends AxUikitBaseOptions {
   dateFormatFallbacks?: array,
   dateTwoDigitYearWrap?: integer,
   timeFormatFallbacks?: array
}

class AxUikit {
   options( opts?: AxUikitFormatterOptions | AxUikitParserOptions ): Object,
   formatter: {
      create( type: string, opts?: AxUikitFormatterOptions ): Function
   },
   parser: {
      error(): { ok: false },
      success( value: any ): { ok: true, value: any },
      create( type: string, opts?: AxUikitParserOptions ): Function
   },
   localized( i18n: AxI18n ): AxUikit
}

/cc @alex3683, @x1B

Edit: parser.create() and formatter.create() stay because parser.error() and parser.success( value ) exist.

@jpommerening
Copy link
Member Author

Published w/ in v2.0.0-alpha.4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant