Module: Gen::Locales

Defined in:
docs/api/stubs/generated_app.rb

Overview

What spin run gen writes into gen/locales.rb (cybertrain/generator/locales_emitter.rb): every config/locales/**/*.yml, read in path order (a later file’s key wins), compiled into the binary as two tables, texts and lists (day and month names). The file begins with require "cybertrain/i18n" and its last line hands Locales.resolver and Locales.list_resolver to I18n.install_dictionary. An application with no dictionary gets empty tables. The values below are for a config/locales/ja.yml with ja: { posts: { index: { title: 投稿 } } }.

Class Method Summary collapse

Class Method Details

.list_resolver ⇒ Proc

Returns ->(key) { Gen::Locales.lookup_list(key) }.

Returns:

  • (Proc) —

    ->(key) { Gen::Locales.lookup_list(key) }



1358
# File 'docs/api/stubs/generated_app.rb', line 1358

def self.list_resolver = ->(key) { Gen::Locales.lookup_list(key) }

.lookup(key) ⇒ String?

Returns "投稿"; nil for a key that is absent, a list or a mapping.

Parameters:

  • key (String) —

    the full key, locale first ("ja.posts.index.title")

Returns:

  • (String, nil) —

    "投稿"; nil for a key that is absent, a list or a mapping



1344
# File 'docs/api/stubs/generated_app.rb', line 1344

def self.lookup(key); end

.lookup_list(key) ⇒ Array<String>

Returns ["Sun", "Mon", ...]; empty for a key that is absent or a text.

Parameters:

  • key (String) —

    the full key ("en.date.abbr_day_names")

Returns:

  • (Array<String>) —

    ["Sun", "Mon", ...]; empty for a key that is absent or a text



1350
# File 'docs/api/stubs/generated_app.rb', line 1350

def self.lookup_list(key); end

.resolver ⇒ Proc

Returns ->(key) { Gen::Locales.lookup(key) }.

Returns:

  • (Proc) —

    ->(key) { Gen::Locales.lookup(key) }



1354
# File 'docs/api/stubs/generated_app.rb', line 1354

def self.resolver = ->(key) { Gen::Locales.lookup(key) }