Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/wikimedia-gadgets/HanAssist
- Owner: wikimedia-gadgets
- License: bsd-3-clause
- Created: 2022-06-06T12:15:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-06T15:31:32.000Z (19 days ago)
- Last Synced: 2024-12-06T15:46:44.328Z (19 days ago)
- Topics: mediawiki, mediawiki-gadget, wikipedia
- Language: TypeScript
- Homepage: https://zh.wikipedia.org/wiki/Wikipedia:HanAssist
- Size: 397 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.EN.MD
- Contributing: CONTRIBUTING.MD
- License: LICENSE
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.