Skip to content

Commit a66339f

Browse files
committed
Use plan.owner.language for plan.language
Prior to this change, `LocaleService.default_locale` was always assigned to `json.language`. - Now we use `plan.owner&.language&.abbreviation` (or `LocaleService.default_locale` as a fallback)
1 parent 95c6c89 commit a66339f

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

app/presenters/api/v2/language_presenter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class << self
7575
# Convert the incoming 2 (e.g. en - ISO 639-1) or 2+region (e.g. en-UK)
7676
# into the 3 character code (e.g. eng - ISO 639-2)
7777
def three_char_code(lang:)
78+
lang ||= LocaleService.default_locale
7879
two_char_code = lang.to_s.split('-').first
7980
LANGUAGE_MAP[two_char_code.to_sym]
8081
end

app/views/api/v2/plans/_show.json.jbuilder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ presenter = Api::V2::PlanPresenter.new(plan: plan, complete: @complete)
1414
json.title plan.title
1515
json.description plan.description
1616
json.language Api::V2::LanguagePresenter.three_char_code(
17-
lang: LocaleService.default_locale
17+
lang: plan.owner&.language&.abbreviation
1818
)
1919
json.created plan.created_at.to_formatted_s(:iso8601)
2020
json.modified plan.updated_at.to_formatted_s(:iso8601)

0 commit comments

Comments
 (0)