Git Product home page Git Product logo

num-translator's Introduction

numbers-to-text-converter

!!! ONLY FOR INTEGER NUMBERS, IN RANGE [0; 999 999 999 999] !!!

Перевод числа в текстовый вариант (прописью) для языков:

  • Казахский
  • Русский
  • Латинский Казахский
  • Английский

How to use:

String translatedNumber = new NumTranslator(Language.RUS).translate(long number);

Example of working:

assertEquals(new NumTranslator(KAZ).translate(123_123_120_100L), 
            "бір жүз жиырма үш миллиард бір жүз жиырма үш миллион бір жүз жиырма мың бір жүз");

assertEquals(new NumTranslator(QAZ).translate(123_123_120_100L), 
            "bir júz jıyrma úsh mıllıard bir júz jıyrma úsh mıllıon bir júz jıyrma myń bir júz");

assertEquals(new NumTranslator(ENG).translate(123_123_120_100L), 
            "one hundred twenty three billion one hundred twenty three million one hundred twenty thousand one hundred");

assertEquals(new NumTranslator(RUS).translate(123_123_120_100L), 
            "сто двадцать три миллиарда сто двадцать три миллиона сто двадцать тысяч сто");

assertEquals(new NumTranslator(RUS).translate(0), "ноль");
assertEquals(new NumTranslator(KAZ).translate(0), "нөл");
assertEquals(new NumTranslator(QAZ).translate(0), "nól");
assertEquals(new NumTranslator(ENG).translate(0), "zero");

Как добавить новый язык?

  1. Добавить в enum
  2. Создать класс CurrentLangBlockMapper implements IBlockMapper - реализовать 3 метода для перевода цифр в слова (units, decimals, hundreds)
  3. В классе BlockPosition добавить перевод Классов числа (тысяч, млн, млрд)
  4. Затронуть init mapper в конструкторе ThreeDigitsBlock

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.