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.
var swapLang = require('swap-lang');
<!-- OR -->
import swapLang from 'swap-lang';
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.
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.
Code | Language |
---|---|
{'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 |
yarn run test