Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ const y18n = (opts) => {
return _y18n(opts, shim)
}

export { Y18N } from './build/lib/index.js'
export default y18n
4 changes: 2 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface PlatformShim {
}

let shim: PlatformShim
class Y18N {
export class Y18N {
directory: string;
updateFiles: boolean;
locale: string;
Expand Down Expand Up @@ -189,7 +189,7 @@ class Y18N {
if (shim.fs.readFileSync) {
localeLookup = JSON.parse(shim.fs.readFileSync(languageFile, 'utf-8'))
}
} catch (err) {
} catch (err: any) {
if (err instanceof SyntaxError) {
err.message = 'syntax error in ' + languageFile
}
Expand Down
15 changes: 13 additions & 2 deletions test/esm/y18n-test.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
/* global describe, it */

import * as assert from 'assert'
import y18n from '../../index.mjs'
import y18n, { Y18N } from '../../index.mjs'

describe('y18n', function () {
it('__ smoke test', function () {
const __ = y18n({
locale: 'pirate',
directory: './test/locales'
}).__

assert.strictEqual(
__`Hi, ${'Ben'} ${'Coe'}!`,
'Yarr! Shiver me timbers, why \'tis Ben Coe!'
)
})

it('exposes an explicit construction', () => {
const y18nOpts = {
locale: 'pirate',
directory: './test/locales'
}
const _y18n = new Y18N(y18nOpts)
assert.strictEqual(
_y18n.__`Hi, ${'Ben'} ${'Coe'}!`,
'Yarr! Shiver me timbers, why \'tis Ben Coe!'
)
})
})