From 65142562b72c0f5586a66d3ae09fbb9eba7d1281 Mon Sep 17 00:00:00 2001 From: Siddharth VP Date: Sat, 15 May 2021 18:43:06 +0530 Subject: [PATCH] Readme update; bump version --- README.md | 15 ++++++++++++--- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 04548bf..7099d98 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wikimedia/orange-i18n/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/orange-i18n.svg?style=flat)](https://www.npmjs.com/package/orange-i18n) -Orange-i18n is a fork of [**banana-i18n**](https://www.npmjs.com/package/banana-i18n) intended for use in gadgets on Wikimedia sites. +Orange-i18n is a fork of [**banana-i18n**](https://www.npmjs.com/package/banana-i18n) optimised for use in gadgets on Wikimedia sites. Some of the changes done in this fork have been merged upstream. The only significant change here now is the use of MW plural rules rather than `Intl` based ones. -PATCHES: +#### Patches 1. Replaced use of `Intl.PluralRules` with `mw.libs.pluralruleparser` and a pluralrules.json data file - `Intl.PluralRules` is not supported in IE 11 and Safari <13, for which MediaWiki still provides Grade A support. - The JSON data file is from version 1.2 of banana-i18n which used it along with the [cldrpluralruleparser](https://www.npmjs.com/package/cldrpluralruleparser) npm package. cldrpluralruleparser is equivalent to mediawiki.libs.pluralruleparser. The former is kept as a dev dependency for mocking the latter in tests. @@ -21,7 +21,16 @@ PATCHES: - MERGED UPSTREAM in https://github.com/wikimedia/banana-i18n/pull/46 5. Added TypeScript type definitions. -Run `npm run build` for a full build. +#### Removed/missing features: +Certain features are removed/missing in order to keep the library light-weight. +1. HTML sanitisation + - Messages from untrusted sources should not be directly used as HTML, as this library does not provide runtime sanitisation of messages. Ideally, use a build step to sanitise them keeping only trusted HTML tags and attributes. +2. Wikilink, external link syntax parsing + - This can be implemented more appropriately in the consumer script side. Since neither this library nor its parent banana-i18n use different parsing modes like mediawiki.JQueryMsg, parsing wikilinks to `` tags may not be always desirable (for example, wikilinks in edit summaries). +3. Built-in fallback language resolution data + - Fallback languages need to be explicitly set using `banana.setFallbackLocales()` method, so that the list of fallback languages does not need to be present in the library code. It is suggested to use a pre-processed i18n files that contain all fallback languages messages already resolved. This saves the time and bandwidth needed to fetch multiple i18n files. + +Twinkle-core uses an [i18n build script](https://github.com/wikimedia-gadgets/twinkle-core/blob/master/scripts/build-i18n.js) for build-time message sanitisation and fallback language resolution. ### Custom builds Another build script is included that tailors a build to include only the code and data required for a given set of languages. This optimises the build from about 27000 bytes to just about 8000 bytes in many situations. diff --git a/package-lock.json b/package-lock.json index b807e05..11c351b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "orange-i18n", - "version": "2.0.0", + "version": "3.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "2.0.0", + "version": "3.0.0", "license": "MIT", "devDependencies": { "@rollup/plugin-commonjs": "^17.1.0", diff --git a/package.json b/package.json index ec7af89..8264c2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orange-i18n", - "version": "2.0.0", + "version": "3.0.0", "description": "Banana Internationalization library", "main": "dist/banana-i18n.js", "typings": "types/index.d.ts",