Skip to content

Instantly share code, notes, and snippets.

@crusadergo
Last active October 26, 2017 15:48
Show Gist options
  • Save crusadergo/5c4782fd270590ed649759d7757e5dc4 to your computer and use it in GitHub Desktop.
Save crusadergo/5c4782fd270590ed649759d7757e5dc4 to your computer and use it in GitHub Desktop.
1st method: Returns current about_us pages data. They depend on locale and brand. 2nd method: Returns current text direction stored in locales.yml or default if current doesn't exist
# @fn def about_us_menu_pages {{{
# @brief Returns current about_us pages data. They depend on locale and brand
#
# @return [Array<Hash>] Returns an array of hashes with current pages data
# title: page title
# filename: file name
# href: page url
def about_us_menu_pages
cached_data = Cache.instance.lazy Cache::TTL::VIEWS, locale: Locale.current do
data = [
{ title: _('Company'), filename: 'about_us.md', href: 'about' },
{ title: _('Board of directors'), filename: 'bod.md', href: 'board_of_directors' },
]
data.select { |entry| localized_filepath(Constants::YAML_DATA_DIR / 'md' / entry[:filename]).exist? }
end
IceNine.deep_freeze Baseline::Utils.deep_symbolize_keys(cached_data)
end # }}}
# @fn def current_text_direction {{{
# @brief Returns current text direction stored in locales.yml or default if current doesn't exist
#
# @return [String] Return a string like 'rtl' or 'ltr'
def current_text_direction
default_text_direction = 'ltr'
available_locales[current_locale_name].text_direction || default_text_direction
end # }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment