How to use the transliteration.transliterate function in transliteration

To help you get started, we’ve selected a few transliteration examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Dragory / ZeppelinBot / backend / src / plugins / Automod.ts View on Github external
protected evaluateMatchRegexTrigger(trigger: TMatchRegexTrigger, str: string): null | string {
    if (trigger.normalize) {
      str = transliterate(str);
    }

    // TODO: Time limit regexes
    for (const pattern of trigger.patterns) {
      const regex = new RegExp(pattern, trigger.case_sensitive ? "" : "i");
      const test = regex.test(str);
      if (test) return regex.source;
    }

    return null;
  }
github retorquere / zotero-better-bibtex / content / key-manager / formatter.ts View on Github external
if (mode === 'japanese') mode = null
    const replace = {
      german: {
        '\u00E4': 'ae', // tslint:disable-line:object-literal-key-quotes
        '\u00F6': 'oe', // tslint:disable-line:object-literal-key-quotes
        '\u00FC': 'ue', // tslint:disable-line:object-literal-key-quotes
        '\u00C4': 'Ae', // tslint:disable-line:object-literal-key-quotes
        '\u00D6': 'Oe', // tslint:disable-line:object-literal-key-quotes
        '\u00DC': 'Ue', // tslint:disable-line:object-literal-key-quotes
      },
    }[mode]
    if (mode && !replace) throw new Error(`Unsupported fold mode "${mode}"`)

    if (kuroshiro.enabled) str = kuroshiro.convert(str, {to: 'romaji'})
    str = transliterate(str || '', {
      unknown: '\uFFFD', // unicode replacement char
      replace,
    })

    str = fold2ascii(str)

    return str
  }
  private clean(str) {
github quanglam2807 / translatium / src / helpers / translate-text.js View on Github external
.then((response) => {
        const langs = response.lang.split('-');

        output.inputLang = langs[0];
        output.outputLang = outputLang;
        output.inputText = inputText;
        output.outputText = outputLang === 'zh-TW' ? mConv.phrase('s2t', response.text[0]) : response.text[0];

        if (outputLang.startsWith('zh')) {
          const outputRoman = tr(response.text[0]);
          if (outputRoman !== response.text[0]) {
            output.outputRoman = outputRoman;
          }
        }

        if (inputLang === 'zh') {
          const inputRoman = tr(inputText);
          if (inputRoman !== inputText) {
            output.inputRoman = inputRoman;
          }
        }

        if (output.outputRoman === output.outputText) output.outputRoman = undefined;
      }),
  );
github quanglam2807 / translatium / src / helpers / translate-text.js View on Github external
const langs = response.lang.split('-');

        output.inputLang = langs[0];
        output.outputLang = outputLang;
        output.inputText = inputText;
        output.outputText = outputLang === 'zh-TW' ? mConv.phrase('s2t', response.text[0]) : response.text[0];

        if (outputLang.startsWith('zh')) {
          const outputRoman = tr(response.text[0]);
          if (outputRoman !== response.text[0]) {
            output.outputRoman = outputRoman;
          }
        }

        if (inputLang === 'zh') {
          const inputRoman = tr(inputText);
          if (inputRoman !== inputText) {
            output.inputRoman = inputRoman;
          }
        }

        if (output.outputRoman === output.outputText) output.outputRoman = undefined;
      }),
  );
github longjiang / zerotohero-cli / src / components / WordBlock.vue View on Github external
mounted() {
    if (!this.transliteration && this.$hasFeature('transliteration')) {
      if (this.token && this.token.candidates && this.token.candidates.length > 0) {
        if (this.$l2.code === 'ja' && this.token.candidates[0].kana) {
          this.transliteration = this.token.candidates[0].kana
        } else if (['zh', 'nan', 'hak'].includes(this.$l2.code) && this.token.candidates[0].pinyin) {
          this.transliteration = this.token.candidates[0].pinyin
        } else if (this.$l2.code === 'yue' && this.token.candidates[0].jyutping) {
          this.transliteration = this.token.candidates[0].jyutping
        } else {
          this.transliteration = tr(this.token.candidates[0].head)
        }
      }
      if (!this.transliteration && !['ja', 'zh', 'nan', 'hak'].includes(this.$l2.code)) {
        this.transliteration = tr(this.text)
      }
    }
    this.update()
  },
  watch: {
github RandomAPI / Randomuser.me-Node / api / .nextRelease / api.js View on Github external
});

        let timezone = JSON.parse(randomItem(this.datasets.common.timezones));
        this.include('location', {
          street: range(1, 9999) + ' ' + randomItem(this.datasets[nat].street),
          city: randomItem(this.datasets[nat].cities),
          state: randomItem(this.datasets[nat].states),
          postcode: range(10000, 99999),
          coordinates: {
            latitude: faker.address.latitude(),
            longitude: faker.address.longitude()
          },
          timezone
        });
    
        this.include('email', tr.transliterate(name[0]) + '.' + tr.transliterate(name[1]).replace(/ /g, '') + '@example.com');
    
        let salt = random(2, 8);
        let password = this.password === undefined ? randomItem(this.datasets.common.passwords) : this.genPassword();
        this.include('login', {
          uuid: faker.random.uuid(),
          username: randomItem(this.datasets.common.user1) + randomItem(this.datasets.common.user2) + range(100, 999),
          password,
          salt:   salt,
          md5:    crypto.createHash('md5').update(password + salt).digest('hex'),
          sha1:   crypto.createHash('sha1').update(password + salt).digest('hex'),
          sha256: crypto.createHash('sha256').update(password + salt).digest('hex')
        });
    
        let dob = range(-800000000000, this.constantTime * 1000 - 86400000 * 365 * 21);
        let dobDate = new Date(dob);
github GetPublii / Publii / app / back-end / helpers / slug.js View on Github external
function createSlug(textToSlugify, filenameMode = false, saveLowerChars = false) {
    textToSlugify = transliterate(textToSlugify);

    if(!filenameMode) {
        if(saveLowerChars) {
            slug.defaults.mode = 'rfc3986-non-unicode-with-dots-no-lower';
        }

        textToSlugify = slug(textToSlugify);
        slug.defaults.mode = 'rfc3986-non-unicode';
    } else {
        slug.defaults.mode = 'rfc3986-non-unicode-with-dots';
        textToSlugify = slug(textToSlugify);
        slug.defaults.mode = 'rfc3986-non-unicode';
    }

    return textToSlugify;
}
github getgridea / gridea / src / helpers / slug.ts View on Github external
function createSlug(textToSlugify: any, filenameMode = false, saveLowerChars = false) {
  textToSlugify = transliterate(textToSlugify)

  if (!filenameMode) {
    if (saveLowerChars) {
      slug.defaults.mode = 'rfc3986-non-unicode-with-dots-no-lower'
    }

    textToSlugify = slug(textToSlugify)
    slug.defaults.mode = 'rfc3986-non-unicode'
  } else {
    slug.defaults.mode = 'rfc3986-non-unicode-with-dots'
    textToSlugify = slug(textToSlugify)
    slug.defaults.mode = 'rfc3986-non-unicode'
  }

  return textToSlugify
}

transliteration

Unicode to ACSII transliteration / slugify module for node.js, browser, Web Worker, ReactNative and CLI.

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis