Rosetta
Constants
Class methods
Returns a String with approximate distance in time between from and
to. For example:
Rosetta.distance_of_time_in_words(
Time.utc(2021, 10, 15, 8, 0, 0),
Time.utc(2021, 10, 15, 8, 0, 5))
)
# => "5 seconds"
Most of the code for this method is borrowed from Lucky.
Interpolates a given string with the values from the given hash or named tuple.
Gets the current locale at runtime using the config instance stored in the current fiber.
Sets the current locale at runtime using the config instance stored in the current fiber.
Uses a given format to localize a given Time object, for example:
Rosetta.localize_time(Time.local, "%d %b %Y %H:%M:%S")
Pluralizes a given pluralizable translation.
Returns a String with approximate distance in time between from and
current moment.
time_ago_in_words(Time.utc(2019, 8, 30))
# => "about a month"
# gives the same result as:
distance_of_time_in_words(Time.utc(2019, 8, 30), Time.utc)
# => "about a month"
See more examples in #distance_of_time_in_words.
Returns a String with approximate distance in time between current
moment and future date.
time_from_now_in_words(Time.utc(2022, 8, 30))
# => "about a year"
# gives the same result as:
distance_of_time_in_words(Time.utc, Time.utc(2022, 8, 30))
# => "about a year"
See more examples in #distance_of_time_in_words.
Macros
Localizes a date, for example:
Rosetta.date.t(Time.local)
Rosetta.date.t({2021, 8, 20})
Rosetta.date(:long).l(Time.local)
Rosetta.date("%a, %d %b %Y").l(Time.local.date)
Finds the translations for the given key as a dedicated class instance for
the translation, which inherits from Rosetta::Translation.
If the key does not exist, adn no default value is given, a compile error will be raised.
Localizes a numeric value, for example:
Rosetta.number.t(123_456.789)
Rosetta.number(:custom).l(123_456.789)
Localizes time, for example:
Rosetta.time.t(Time.local)
Rosetta.time(:short).l(Time.local)
Rosetta.time("%d %b %Y %H:%M:%S").l(Time.local)
Nested types
- Rosetta::AvailableLocales
- Rosetta::Backend
- Rosetta::Config
- Rosetta::CountArg
- Rosetta::DefaultLocale
- Rosetta::DefaultPluralizationRules
- Rosetta::DefaultTranslation
- Rosetta::FallbackRules
- Rosetta::Fallbacks
- Rosetta::InterpolatedTranslation
- Rosetta::InterpolationArgumentException
- Rosetta::Localizable
- Rosetta::LocalizedNumber
- Rosetta::LocalizedTime
- Rosetta::Lucky
- Rosetta::Parser
- Rosetta::Pluralization
- Rosetta::PluralizationRules
- Rosetta::PluralizedTranslation
- Rosetta::SimpleTranslation
- Rosetta::Translatable
- Rosetta::Translation
- Rosetta::Translations
- Rosetta::TranslationsHash
- Rosetta::VariantMissingException
- Rosetta::VariantsTranslation