![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
= I18n Inflector
i18n-inflector version 2.6.7 (Little Kózka)
== Summary
This library contains a backend module for I18n that adds some extra functionality to standard backend. It overwrites the translate method in a way that it will interpolate additional inflection tokens present in translations.
== Synopsis
require 'i18n-inflector'
I18n.translate( 'to_be', :number => :singular, :tense => :past, :person => 2 ) #=> You were here
I18n.translate('welcome', :gender => :female) #=> Dear Lady
== Why?
You can use I18n Inflector to (relatively easy) create translations for highly inflected languages (like those belonging to Slavic language family). You can also use it in translation services that may operate on sentences instead of exact words.
== When?
It is intended to be used in a web projects or other projects where translations are performed by many people, yet there is a need to inflect sentences with some external variables. To achieve similar functionality lambdas can be used but including many Proc objects might be considered unsafe or memory consuming.
See i18n-inflector-rails[https://rubygems.org/gems/i18n-inflector-rails] if you need Rails integration.
== How?
I18n Inflector lets you build you own inflection patterns contained in translation entries. The patterns may contain simple conditions and tokens, which combined with parameters passed to +I18n.translate+ method can produce inflected strings.
== Features
== Description
The I18n Inflector extends the translate method from I18n in a way that it will interpolate additional inflection tokens present in translations. These tokens may appear in patterns which are contained within @{ and } symbols. Configuration is stored also in translation data, in a scope .i18n.inflections, where locale is a locale subtree.
You can create your own inflection kinds (gender, title, person, time, author, etc.) of tokens to group them in a meaningful, semantical sets. That means you can apply Inflector to do simple inflection by a gender or a person, when some language requires it.
It adds the +inflector+ object to the default backend so you can use many methods for accessing loaded inflection data at runtime, or to set up global switches that are controlling the engine.
== Short example
Example configuration which uses translation data:
en: i18n: inflections: gender: f: "female" m: "male" n: "neuter" female: @f male: @m default: n
Example translation data:
en: welcome: "Dear @{f:Lady|m:Sir|n:You|All}!"
@same_but_as_key:
f: "Lady"
m: "Sir"
n: "You"
@prefix: "Dear "
@suffix: "!"
@free: "All"
=== Note about YAML parsing
The example above is not compatible with Psych parser, which is used by Rails 3. There are two ways to solve that problem.
First is to change a YAML file and replace any value that has special meaning with a symbol:
en: i18n: inflections: gender: f: "female" m: "male" n: "neuter" female: :@f male: :@m default: :n
Second way is to use other parser by adding to +config/boot.rb+:
require 'yaml' YAML::ENGINE.yamler = 'syck'
== New features
From version 2.1.0 the Inflector supports so called named patterns, which can be used if there is a need to be strict and/or to use the same token names but assigned to different kinds. Example:
welcome: "Dear @gender{f:Lady|m:Sir|n:You|All}"
From version 2.2.0 the Inflector supports complex patterns, which can be used to inflect some sentence or a word by more than a one kind. That might be very helpful for highly inflected languages. An example pattern:
welcome: "Dear @gender+number{f+s:Lady|f+p:Ladies|m+s:Sir|m+p:Gentlemen|All}"
== Requirements
== Download
==== Source code
==== Gem
== Installation
== Detailed example
YAML:
en: i18n: inflections: gender: f: "female" m: "male" n: "neuter" o: "other" default: n
welcome: "Dear @{f:Lady|m:Sir|n:You|All}"
Code:
I18n.t('welcome')
I18n.t('welcome', :gender => :m)
I18n.t('welcome', :gender => :unknown)
I18n.inflector.options.unknown_defaults = false I18n.t('welcome', :gender => :unknown)
I18n.t('welcome', :gender => :o)
I18n.inflector.options.excluded_defaults = true I18n.t('welcome', :gender => :o)
== More information
== Tests
You can run tests both with
== Common rake tasks
== Credits
{Heise Media Polska}[http://www.heise-online.pl/] supports Free Software and has contributed to this library by paying for my food during the coding.
== Donations
If you like my work you can send me some BitCoins:
Or you can endorse my skills on LinkedIn:
== License
Copyright (c) 2011,2012 by Paweł Wilk.
i18n-inflector is copyrighted software owned by Paweł Wilk (pw@gnu.org). You may redistribute and/or modify this software as long as you comply with either the terms of the LGPL (see {file:docs/LGPL}), or Ruby's license (see {file:docs/COPYING}).
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
FAQs
Unknown package
We found that i18n-inflector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.