Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wikimedia-gadgets/HanAssist

A simple MediaWiki gadget to ease Chinese variant handling in user scripts and gadgets.
https://github.com/wikimedia-gadgets/HanAssist

mediawiki mediawiki-gadget wikipedia

Last synced: 8 days ago
JSON representation

A simple MediaWiki gadget to ease Chinese variant handling in user scripts and gadgets.

Awesome Lists containing this project

README

        

# HanAssist
[简体中文](./README.MD)

HanAssist is a helper gadget on Chinese Wikipedia to ease Chinese variant handling in user scripts and gadgets. It provides `conv`, `convByVar` and `batchConv` functions on the wiki.

```js
// For gadgets, add HanAssist as a dependency in the definition
const { conv, convByVar } = require( 'ext.gadget.HanAssist' );

// Also can be loaded dynamically
mw.loader.using( 'ext.gadget.HanAssist' ).then( ( require ) => {
const { conv, convByVar } = require( 'ext.gadget.HanAssist' );
// ...
} );

conv( { hans: 'Simplified Chinese content', hant: 'Traditional Chinese content' } );
// => If page language is zh-hans/zh-cn/zh-sg/zh-my: 'Simplified Chinese content'; zh-hant/zh-tw/zh-hk/zh-mo: 'Traditional Chinese content'

convByVar( { hans: 'Simplified Chinese content', hant: 'Traditional Chinese content' } );
// => If page variant is zh-hans/zh-cn/zh-sg/zh-my: 'Simplified Chinese content'; zh-hant/zh-tw/zh-hk/zh-mo: 'Traditional Chinese content'

// Due to technical limitations, if HanAssist is on another wiki, functions will be exported as members of mw.libs.HanAssist
mw.loader.load( 'https://another.wiki/w/index.php?title=MediaWiki:Gadget-HanAssist.js&action=raw&ctype=text/javascript' );
// Usage:
// mw.libs.HanAssist.conv( ... );
// mw.libs.HanAssist.convByVar( ... );
```

Since this gadget is mainly for Chinese users, most of its documentation is written in Chinese. For building instructions, see [CONTRIBUTING.MD](./CONTRIBUTING.MD). There is a TypeScript type definition at [typings.d.ts](./typings.d.ts) specially for MediaWiki frontend development.