diff --git a/.size-limit.js b/.size-limit.js index 931bb146..9d38a4e8 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -2,61 +2,61 @@ module.exports = [ { name: 'i18n-string', path: 'dist/i18n.string.min.js', - limit: '945 b', + limit: '948 b', }, { name: 'typed-i18n-string', path: 'dist/i18n.typed.string.min.js', - limit: '949 b', + limit: '953 b', }, { name: 'i18n-object', path: 'dist/i18n.object.min.js', - limit: '1086 b', + limit: '1089 b', }, { name: 'typed-i18n-object', path: 'dist/i18n.typed.object.min.js', - limit: '1090 b', + limit: '1095 b', }, { name: 'i18n-instance', path: 'dist/i18n.instance.min.js', - limit: '1117 b', + limit: '1119 b', }, { name: 'all together', path: 'dist/i18n.all.min.js', - limit: '1192 b', + limit: '1194 b', }, { name: 'adapter-angular', path: 'angular/index.min.mjs', - limit: '1225 b', + limit: '1230 b', ignore: ['angular'], }, { name: 'adapter-react', path: 'react/index.min.mjs', - limit: '1560 b', + limit: '1562 b', ignore: ['react'], }, { name: 'adapter-solid', path: 'solid/index.min.mjs', - limit: '1402 b', + limit: '1403 b', ignore: ['solid-js'], }, { name: 'adapter-svelte', path: 'svelte/index.min.mjs', - limit: '1339 b', + limit: '1342 b', ignore: ['svelte'], }, { name: 'adapter-vue', path: 'vue/index.min.mjs', - limit: '1253 b', + limit: '1256 b', ignore: ['vue'], }, ] diff --git a/CHANGELOG.md b/CHANGELOG.md index ac1ab906..d1415760 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ # Version 5 +## 5.26.0 (2023-08-01) + +Feat: + - improved plural rules support for polnish [#672](https://github.com/ivanhofer/typesafe-i18n/issues/672) + ## 5.25.1 (2023-07-20) Fix: diff --git a/README.md b/README.md index 1edc93c7..12d93bfc 100644 --- a/README.md +++ b/README.md @@ -233,18 +233,18 @@ The footprint of the `typesafe-i18n` package is smaller compared to other existi These parts are bundled into the [core functions](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/runtime#usage). The sizes of the core functionalities are: -- [i18nString](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/runtime#i18nString): 945 bytes gzipped -- [i18nObject](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/runtime#i18nObject): 1086 bytes gzipped -- [i18n](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/runtime#i18n): 1117 bytes gzipped +- [i18nString](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/runtime#i18nString): 948 bytes gzipped +- [i18nObject](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/runtime#i18nObject): 1089 bytes gzipped +- [i18n](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/runtime#i18n): 1119 bytes gzipped Apart from that there can be a small overhead depending on which utilities and wrappers you use. There also exists a useful wrapper for some frameworks: -- [`typesafe-i18n` angular-service](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-angular): 1225 bytes gzipped -- [`typesafe-i18n` react-context](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-react): 1560 bytes gzipped -- [`typesafe-i18n` solid-context](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-solid): 1402 bytes gzipped -- [`typesafe-i18n` svelte-store](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-svelte): 1339 bytes gzipped -- [`typesafe-i18n` vue-plugin](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-vue): 1253 bytes gzipped +- [`typesafe-i18n` angular-service](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-angular): 1230 bytes gzipped +- [`typesafe-i18n` react-context](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-react): 1562 bytes gzipped +- [`typesafe-i18n` solid-context](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-solid): 1403 bytes gzipped +- [`typesafe-i18n` svelte-store](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-svelte): 1342 bytes gzipped +- [`typesafe-i18n` vue-plugin](https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-vue): 1256 bytes gzipped diff --git a/packages/runtime/src/core.mts b/packages/runtime/src/core.mts index bcdcb1b7..a313fae7 100644 --- a/packages/runtime/src/core.mts +++ b/packages/runtime/src/core.mts @@ -157,9 +157,9 @@ const getPlural = (pluralRules: Intl.PluralRules, { z, o, t, f, m, r }: BasicPlu case 'two': return t case 'few': - return f + return f ?? r case 'many': - return m + return m ?? r default: return r } diff --git a/packages/runtime/src/util.object.test.ts b/packages/runtime/src/util.object.test.ts index f56e7588..2103d7b6 100644 --- a/packages/runtime/src/util.object.test.ts +++ b/packages/runtime/src/util.object.test.ts @@ -267,4 +267,16 @@ test('switch-case with comma 2', () => // -------------------------------------------------------------------------------------------------------------------- +const LL10 = i18nObject('pl', { + MULTIPLE_PARAMS_PLURAL: '{0} banana{{s}} and {1} apple{{s}}', + SINGULAR_PLURAL: '{{ one item | ?? items }}', +}) + +test('multiple params plural for language without PluralRule other', () => + assert.is(LL10.MULTIPLE_PARAMS_PLURAL(1, 2), '1 banana and 2 apples')) +test('plural zero: one for language without PluralRule other', () => assert.is(LL10.SINGULAR_PLURAL(1), 'one item')) +test('plural zero: ?? for language without PluralRule other', () => assert.is(LL10.SINGULAR_PLURAL(5), '5 items')) + +// -------------------------------------------------------------------------------------------------------------------- + test.run() diff --git a/packages/version.ts b/packages/version.ts index 3db4545d..d504c1d9 100644 --- a/packages/version.ts +++ b/packages/version.ts @@ -1,2 +1,2 @@ // this file gets auto-generated -export const version = '5.25.0' +export const version = '5.25.1'