Skip to content

Add support for parentLocales#38

Merged
tigrish merged 1 commit intoruby-i18n:masterfrom
retailnext:parentlocales
Nov 28, 2016
Merged

Add support for parentLocales#38
tigrish merged 1 commit intoruby-i18n:masterfrom
retailnext:parentlocales

Conversation

@natemueller
Copy link
Copy Markdown

Use the parentLocales section to figure out the correct fallback
locales. Can not use customization feature of I18n::Locale::Fallbacks
since it always places the default parent local before any customizations.

Copy link
Copy Markdown
Collaborator

@camertron camertron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have approval rights here, but it looks good to me :)

Comment thread lib/cldr/export.rb Outdated

def locales(locale, component, options)
locale = locale.to_s.gsub('_', '-').to_sym
to_i18n = lambda {|l| l.to_s.gsub('_', '-').to_sym }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why lambdas and not regular 'ol methods?

Comment thread lib/cldr/export.rb Outdated
I18n::Locale::Fallbacks.new([locale])[locale]
defined_parents = Cldr::Export::Data::ParentLocales.new

ancestory = [locale]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: "ancestry"

Use the parentLocales section to figure out the correct fallback
locales.  Can not use customization feature of I18n::Locale::Fallbacks
since it always places the default parent local before any customizations.
@tigrish tigrish merged commit 98b4855 into ruby-i18n:master Nov 28, 2016
@davispuh
Copy link
Copy Markdown
Contributor

davispuh commented Jun 5, 2017

It seems like there's some bug

$ thor cldr:export

ruby-cldr/lib/cldr/export/data/parent_locales.rb:7:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
from ruby-cldr/lib/cldr/export.rb:95:in `new'
from ruby-cldr/lib/cldr/export.rb:95:in `block in locale_based_data'
from ruby-cldr/lib/cldr/export.rb:94:in `each'
from ruby-cldr/lib/cldr/export.rb:94:in `inject'
from ruby-cldr/lib/cldr/export.rb:94:in `locale_based_data'
from ruby-cldr/lib/cldr/export.rb:88:in `data'
from ruby-cldr/lib/cldr/export/yaml.rb:11:in `export'
from ruby-cldr/lib/cldr/export.rb:70:in `block (2 levels) in export'
from ruby-cldr/lib/cldr/export.rb:69:in `each'
from ruby-cldr/lib/cldr/export.rb:69:in `block in export'
from ruby-cldr/lib/cldr/export.rb:68:in `each'
from ruby-cldr/lib/cldr/export.rb:68:in `export'
from ruby-cldr/lib/cldr/thor.rb:27:in `export'
def locale_based_data(component, locale, options = {})
        data = locales(locale, component, options).inject({}) do |result, locale|
            data = Data.const_get(component.to_s.camelize).new(locale)

it calls ParentLocales.new(locale) which doesn't take any argument.

@camertron camertron mentioned this pull request Jun 19, 2017
@camertron
Copy link
Copy Markdown
Collaborator

@davispuh Oops, my bad! I don't use thor cldr:export so I didn't notice it was broken. #40 should fix it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants