Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions 23 pegasus/helpers/hourofcode_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,30 @@ def localized_image(path)

def campaign_date(format)
@country ||= hoc_detect_country
type = HOC_COUNTRIES[@country]['type'] || 'default'
language = HOC_COUNTRIES[@country]['default_language']
id = 'campaign_date_full'

case format
when "start-short"
return HOC_COUNTRIES[@country]['campaign_date_start_short']
id = 'campaign_date_start_short'
when "start-long"
return HOC_COUNTRIES[@country]['campaign_date_start_long']
id = 'campaign_date_start_long'
when "short"
return HOC_COUNTRIES[@country]['campaign_date_short']
id = 'campaign_date_short'
when "full"
return HOC_COUNTRIES[@country]['campaign_date_full']
id = 'campaign_date_full'
when "year"
return HOC_COUNTRIES[@country]['campaign_date_year']
id = 'campaign_date_year'
when "full-year"
return HOC_COUNTRIES[@country]['campaign_date_full_year']
else
return HOC_COUNTRIES[@country]['campaign_date_full']
id = 'campaign_date_full_year'
end

if %w(latam europe africa).include? type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it worth doing the opposite of this? i.e. unless type == 'default'. I feel like it's possible that we add another set of dates and then we would only have to edit countries.json and en.yml

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that's fair, I was worried about the likelihood of someone putting an incorrect type in there, in which case we would want to fall back to default instead of using an id that doesn't exist

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ooo good point!

id = "#{type}_#{id}"
end

return HOC_I18N[language][id] || HOC_I18N['en'][id]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does HOC_COUNTRIES vs. HOC_I18N represent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

HOC_COUNTRIES is the parsed countries.json file as an object. HOC_I18N is all the *.yml files (per language) for the hour of code translation variables--so the new variables I put in en.yml will be in HOC_I18N

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 thanks!

end

def company_count
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.