Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
cldr-plurals-runtime-js
Advanced tools
Javascript runtime for CLDR plural rules generated by camertron/cldr-plurals.
Javascript runtime methods for CLDR plural rules (see camertron/cldr-plurals).
gem install cldr-plurals-runtime-js
const runtime = require('cldr-plurals-runtime');
The CLDR data set contains plural information for numerous languages in an expression-based format defined by Unicode's TR35. The document describes how to determine the various parts of a number and how to use those parts to determine the plural rule. The parts as they appear in TR35 are:
Symbol | Value |
---|---|
n | absolute value of the source number (integer and decimals). |
i | integer digits of n. |
v | number of visible fraction digits in n, with trailing zeros. |
w | number of visible fraction digits in n, without trailing zeros. |
f | visible fractional digits in n, with trailing zeros. |
t | visible fractional digits in n, without trailing zeros. |
cldr-plurals-runtime-js is an implementation of these calculations in Javascript. Rules can be compiled into Javascript using the cldr-plurals rubygem:
require 'cldr-plurals'
rules = CldrPlurals::Compiler::RuleList.new(:ru).tap do |rule_list|
rule_list.add_rule(:one, 'v = 0 and i % 10 = 1 and i % 100 != 11')
rule_list.add_rule(:few, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14')
rule_list.add_rule(:many, 'v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14')
end
js_code = rules.to_code(:javascript)
Once you've produced the Javascript code for the rule list, you can execute them like so:
const runtime = require('cldr-plurals-runtime');
const rule = function() { ... } // code generated above by cldr-plurals
console.log(rule('3', runtime)) // => "few"
No external requirements.
jasmine-node spec/
should do the trick.
1.2.0
FAQs
Javascript runtime for CLDR plural rules generated by camertron/cldr-plurals.
The npm package cldr-plurals-runtime-js receives a total of 2 weekly downloads. As such, cldr-plurals-runtime-js popularity was classified as not popular.
We found that cldr-plurals-runtime-js 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.