No description
Find a file
Constantine Molchanov 92e20f5309
Update README.rst
2021-04-26 12:55:10 +04:00
src Restructure docs. 2020-09-04 10:57:33 +04:00
tests Merge branch 'master' into develop 2019-05-11 22:36:21 +04:00
.gitignore Restructure docs. 2020-09-04 10:57:33 +04:00
.travis.yml Update travis file. 2020-09-04 11:08:08 +04:00
changelog.rst Restructure docs. 2020-09-04 10:57:33 +04:00
CNAME Restructure docs. 2020-09-04 10:57:33 +04:00
docker-compose.yml Fix docs build. 2020-09-04 11:01:16 +04:00
LICENSE Initial commit 2018-12-19 17:23:10 +04:00
loco.nimble Restructure docs. 2020-09-04 10:57:33 +04:00
README.rst Update README.rst 2021-04-26 12:55:10 +04:00

**********************************
Loco: Localization Package for Nim
**********************************

.. image:: https://travis-ci.com/moigagoo/loco.svg?branch=develop
    :alt: Build Status
    :target: https://travis-ci.com/moigagoo/loco

.. image:: https://raw.githubusercontent.com/yglukhov/nimble-tag/master/nimble.png
    :alt: Nimble
    :target: https://nimble.directory/pkg/loco


Loco helps localize Nim apps. Uses classic declaratively defined "zero-one-few-many" language variables, but thanks to Nim's superpowers, you also have code completion and compilation checks for language variables.

*   `Repo <https://github.com/moigagoo/loco>`__

    -   `Issues <https://github.com/moigagoo/loco/issues>`__
    -   `Pull requests <https://github.com/moigagoo/loco/pulls>`__

*   `API index <theindex.html>`__
*   `Changelog <https://github.com/moigagoo/loco/blob/develop/changelog.rst>`__


Quickstart
==========

1.  Install Loco with Nimble:

.. code-block::

    $ nimble install loco


2.  Define localizations with ``loco`` macro:

.. code-block:: nim

    # en_US.nim

    import loco

    loco en:
      hello: "hello"
      users:
        zero: "no users"
        one: "{n} user"
        many: "{n} users"

Argument ``en`` is the name of a *pluralizer*. Pluralizer is a module in ``loco`` that defines pluralization rules for a particural language.

3.  Use them in your code as regular functions:

.. code-block:: nim

    # app.nim

    import en_US

    echo hello() & " world"     # → "hello world"
    echo "there's " & 0.users   # → "there's no users"
    echo "there's " & 1.users   # → "there's 1 user"
    echo "there's " & 12.users  # → "there's 12 users"


Contributing
============

Any contributions are welcome, be it pull requests, code reviews, documentation improvements, bug reports, or feature requests.

If you decide to contribute through code, please run the tests after you change the code:

.. code-block::

    $ docker-compose run tests                  # run all tests in Docker
    $ docker-compose run test tests/testen.nim  # run a single test suite in Docker
    $ nimble test                               # run all tests natively
    $ nim c -r tests/testen.nim                 # run a single test suite natively


❤ Contributors ❤
==================

- `@moigagoo <https://github.com/moigagoo>`__
- `@Nindaleth <https://github.com/Nindaleth>`__