Skip to content

Commit

Permalink
Readme update; bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthvp committed May 15, 2021
1 parent 9ea0037 commit 6514256
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 `<a>` 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.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 6514256

Please sign in to comment.