twitter/twitter-cldr-rb — pull request #139 by KL-7 (2014-10-09 00:00:37+00:00)
Title: Respect pluralization rules during abbreviated numbers formatting.

This is meant to fix #129.

There're still a few TODO's and pending tests, but all necessary code changes are already there. I'm not very happy with the solution myself so I thought I'd put it out for review in case you have some ideas, @camertron.

The problem is that pattern tokenization is done twice. First time we tokenize a sample pattern from the group of patterns that match our number to find out how many digits we need for the pattern. Then we truncate our number based on this information and choose the final pattern that matches pluralization rules for the resulting truncated number (we have to do it like that because pluralization rule for the original number might differ from the pluralization rule for truncated number). My concern is that previously the execution flow was "data_reader -> tokenizer -> formatter" and now it's more like "data_reader -> tokenizer -> formatter -> data_reader -> tokenizer -> formatter" (see `NumberDataReader#truncate_number` method). I don't think it creates any significant overhead or performance issues, it's just the number formatting flow doesn't look as straightforward as it was before. Unfortunately I couldn't figure out how to move things around to make the implementation more transparent.

I'm also waiting for the `ruby-cldr` changes to get into their master (I'm about to submit a PR for them) and #137 to be merged into our master.