This repository has been archived by the owner. It is now read-only.
gettext.cr
gettext.cr
Crystal implementation of gettext. Exposes similar API to Python gettext
with additional support for PO
files.
Installation
-
Add the dependency to your
shard.yml
:dependencies: gettext: github: omarroth/gettext.cr
-
Run
shards install
Usage
require "gettext"
es_mo = Gettext::MoParser.new(File.open("examples/locales/es.mo"))
es_po = Gettext::PoParser.new(File.open("examples/locales/es.po"))
puts es_mo.ngettext("Time: %1 second", "Time: %1 seconds", 10) # => Czas: %1 sekundy
puts es_mo.ngettext("Time: %1 second", 10) # => Time: %1 second
puts es_po.ngettext("Time: %1 second", "Time: %1 seconds", 1) # => Czas: %1 sekunda
puts es_po.ngettext("Time: %1 second", 1) # => Czas: %1 sekunda
translations = Gettext.find("examples/locales", nil)
puts translations.ngettext("es-US", "Time: %1 second", "Time: %1 seconds", 10) # => Czas: %1 sekundy
puts translations.gettext("es", "Logarithmic Scale") # => logaritamska skala
Contributing
- Fork it (https://github.com/omarroth/gettext.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Omar Roth - creator and maintainer
Repository
gettext.cr
Owner
Statistic
- 5
- 0
- 0
- 0
- 1
- over 5 years ago
- May 27, 2019
License
GNU General Public License v3.0
Links
Synced at
Thu, 07 Nov 2024 23:57:40 GMT
Languages