1.0.7 • Published 4 years ago

swap-lang v1.0.7

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Swap Lang

Swap lang allows you to separate the "Basic Latin" character and the "Language specific" character like Japanese, Arabic, etc. The idea came when I worked on the gallery website of UltraSuperNew. The latin character and the japanese don't have the same size and they have the same font and we want to have more control of our typography.

alt text

Usage

Init

var swapLang = require('swap-lang');

<!-- OR -->

import swapLang from 'swap-lang';

Basic usage

const defaultUsage = swapLang('Hello world! こんにちは世界');

// Output
Hello world! <span>こんにちは世界</span>

The basic usage uses Japanese (Katakana, Hiragana, Kanji). If you need an other language, use the example with parameters.

Extended usage

If you want to use a different tag.

const defaultUsage = swapLang('Hello world! مرحبا بالعالم', {lang: 'ar'});

// Output
Hello world! <span>مرحبا</span> <span>بالعالم</span>

If you want to use a class name

const defaultUsage = swapLang('Hello world! こんにちは世界', {class: 'ja'});

// Output
Hello world! <span class="ja">こんにちは世界</span>

The basic usage uses Japanese (Katakana, Hiragana, Kanji). If you need an other language, use the example with parameters.

Supported Languages

CodeLanguage
{'ar'}Arabic
{'bn'}Bengali
{'bo'}Tibetan
{'el'}Greek & Coptic
{'gu'}Gujarati
{'he'}Hebrew
{'hy'}Armenian
{'ja'}Japanese
{'ka'}Georgian
{'km'}Khmer
{'kn'}Kannada
{'ko'}Korean
{'my'}Birman
{'ml'}Malayalam
{'or'}Oriya
{'sr-cy'}Cyrillic
{'ta'}Tamil
{'te'}Telugu
{'th'}Thai
{'tl'}Tagalog
{'zh'}Chinese

Test

yarn run test
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago