All Projects → wout → rosetta

wout / rosetta

Licence: MIT License
A blazing fast internationalization (i18n) library for Crystal with compile-time key lookup.

Programming Languages

crystal
512 projects
HTML
75241 projects

Projects that are alternatives of or similar to rosetta

Node Gettext
A JavaScript implementation of gettext, a localization framework.
Stars: ✭ 175 (+660.87%)
Mutual labels:  i18n, translation, internationalization, localization, l10n
inlang
Open Source Localization Solution for Software.
Stars: ✭ 160 (+595.65%)
Mutual labels:  i18n, translation, internationalization, localization, l10n
i18n
internationalize projects to Arabic
Stars: ✭ 67 (+191.3%)
Mutual labels:  i18n, translation, internationalization, localization, l10n
Mojito
An automation platform that enables continuous localization.
Stars: ✭ 256 (+1013.04%)
Mutual labels:  i18n, translation, internationalization, localization, l10n
Pseudo Localization
Dynamic pseudo-localization in the browser and nodejs
Stars: ✭ 109 (+373.91%)
Mutual labels:  i18n, translation, internationalization, localization, l10n
Fluent.js
JavaScript implementation of Project Fluent
Stars: ✭ 622 (+2604.35%)
Mutual labels:  i18n, translation, internationalization, localization, l10n
labels
Bolt Labels extension - Translatable labels for Bolt
Stars: ✭ 18 (-21.74%)
Mutual labels:  i18n, translation, internationalization, localization, l10n
Dom I18n
Provides a very basic HTML multilingual support using JavaScript
Stars: ✭ 125 (+443.48%)
Mutual labels:  i18n, translation, internationalization, localization, l10n
Weblate
Web based localization tool with tight version control integration.
Stars: ✭ 2,719 (+11721.74%)
Mutual labels:  i18n, translation, internationalization, localization, l10n
awesome-translations
😎 Awesome lists about Internationalization & localization stuff. l10n, g11n, m17n, i18n. Translations! 🌎🌍
Stars: ✭ 54 (+134.78%)
Mutual labels:  i18n, localization, l10n, locale
stone.js
gettext-like client-side Javascript Internationalization Library
Stars: ✭ 20 (-13.04%)
Mutual labels:  i18n, internationalization, localization, l10n
Angular-Gulp-Boilerplate
Clean but full-featured AngularJS boilerplate using Gulp workflow and best practices
Stars: ✭ 30 (+30.43%)
Mutual labels:  i18n, internationalization, localization, l10n
locale-switcher
Browser Extension to quickly change your browser locale.
Stars: ✭ 75 (+226.09%)
Mutual labels:  internationalization, localization, l10n, locale
React Native Globalize
Internationalization (i18n) for React Native
Stars: ✭ 246 (+969.57%)
Mutual labels:  i18n, internationalization, localization, l10n
I18N
I18N Library for .NET, and Delphi
Stars: ✭ 48 (+108.7%)
Mutual labels:  i18n, internationalization, localization, l10n
msgtools
Tools for Developing Diagnostic Messages
Stars: ✭ 18 (-21.74%)
Mutual labels:  i18n, internationalization, localization, l10n
Serge
Continuous localization platform
Stars: ✭ 212 (+821.74%)
Mutual labels:  i18n, internationalization, localization, l10n
awesome-i18n
🌍 A curated list of i18n resources for all kind of languages and frameworks
Stars: ✭ 205 (+791.3%)
Mutual labels:  i18n, internationalization, localization, l10n
lisan
🌈i18n, Reimagined! 🚀A blazing fast and super small i18n library for Javascript
Stars: ✭ 85 (+269.57%)
Mutual labels:  i18n, internationalization, localization, l10n
android-studio-plugin
Integrate your Android project with Crowdin
Stars: ✭ 52 (+126.09%)
Mutual labels:  i18n, internationalization, localization, l10n

Rosetta

Rosetta logo

A blazing fast internationalization (i18n) library for Crystal with compile-time key lookup. You'll never have a missing translation in your app, ever again.

GitHub GitHub tag (latest SemVer) GitHub Workflow Status

Why use Rosetta?

You'll never have a missing translation

Rosetta is different from other internationalization libraries because it handles key lookup at compile-time rather than runtime. The significant advantage is that you'll be able to find missing translations - or typos in your locale keys - during development rather than after you've deployed your app. This is also true for translation keys in all additional locales.

You'll never have a missing interpolation

In Rosetta, interpolation keys are arguments to the translation method. So if you're missing an argument, the compiler will complain. The parser will also compare interpolation keys in additional locales to the ones found in the default locale, and complain if some are missing.

Rosetta is more than 10x faster than similar libraries

Benchmarking against other libraries which also use YAML or JSON backends, Rosetta is at least 10x faster than any other one.

For simple translations:

crimson-knight/i18n.cr translation 303.57k (  3.29µs) (± 4.62%)  801B/op  702.21× slower
     crystal-i18n/i18n translation  18.07M ( 55.35ns) (± 7.28%)  48.0B/op  12.39× slower
         syeopite/lens translation   5.09M (196.47ns) (± 4.60%)   176B/op  43.98× slower
          wout/rosetta translation 223.86M (  4.47ns) (± 2.20%)   0.0B/op        fastest

For translations with interpolations:

crimson-knight/i18n.cr interpolation 318.12k (  3.14µs) (± 0.85%)    801B/op  108.51× slower
     crystal-i18n/i18n interpolation  65.55k ( 15.26µs) (± 1.01%)  28.2kB/op  664.37× slower
         syeopite/lens interpolation   2.04M (490.17ns) (± 1.35%)    565B/op   21.35× slower
          wout/rosetta interpolation  43.55M ( 22.96ns) (± 4.81%)   80.0B/op         fastest

Rosetta is that much faster because a lot of the hard work happens at compile-time. And because the majority of the data is stored on the stack rather than the heap, out of the scope of garbage collector.

Read more on the official docs page.

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  rosetta:
    github: wout/rosetta
  1. Run shards install

  2. Run bin/rosetta --init

  3. Require the generated config file:

# e.g. src/app_name.cr
require "../config/rosetta"
  1. Include the Rosetta::Translatable mixin:
# e.g. src/pages/main_layout.cr
include Rosetta::Translatable
  1. Localize your app
Rosetta.locale = :es

class Hello::ShowPage < MainLayout
  def content
    h1 r("welcome_message").t(name: "Brian") # => "¡Hola Brian!"
  end
end

Read more on the official docs page.

To-do

  • Add specs for the existing code
  • Make settings accessible to the compiler
  • Send default_locale and available_locales to the parser
  • Implement key comparison between available locales in the parser
  • Add compiler error messages for mismatching keys
  • Implement inferred locale keys at macro level
  • Interpolation (with %{} tag for interpolation keys)
  • Check existence of interpolation keys in all translations at compile-time
  • Translatable mixin
  • Localization of numeric values
  • Localization of date and time values
  • Localizable mixin
  • Locale exceptions
  • Add setup scripts
  • Pluralization (with one/many/other/count/... convention)
  • Implement fallbacks

Development

Make sure you have Guardian.cr installed. Then run:

$ guardian

This will automatically:

  • run ameba for src and spec files
  • run the relevant spec for any file in src
  • run spec file whenever they are saved
  • install shards whenever you save shard.yml

Documentation

Contributing

  1. Fork it (https://github.com/wout/rosetta/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • wout - creator and maintainer

Acknowledgements

This shard pulls inpiration from the following projects:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].