diff --git a/app/components/contents/file_component.html.erb b/app/components/contents/file_component.html.erb
index 3a1754f730..d5118c8700 100644
--- a/app/components/contents/file_component.html.erb
+++ b/app/components/contents/file_component.html.erb
@@ -13,6 +13,7 @@
<%= width %> |
<% end %>
<%= role %> |
+ <%= file_language %> |
<%= tag.span(class: 'bi-check') if publish %> |
<%= tag.span(class: 'bi-check') if shelve %> |
<%= tag.span(class: 'bi-check') if sdrPreserve %> |
diff --git a/app/components/contents/file_component.rb b/app/components/contents/file_component.rb
index 4390993e8a..8b7f57bda6 100644
--- a/app/components/contents/file_component.rb
+++ b/app/components/contents/file_component.rb
@@ -19,8 +19,8 @@ def image?
@image
end
- delegate :access, :administrative, :filename, :hasMimeType, :size, :externalIdentifier, :use, :presentation,
- to: :file
+ delegate :access, :administrative, :filename, :hasMimeType, :size, :externalIdentifier, :use,
+ :presentation, :languageTag, to: :file
delegate :publish, :shelve, :sdrPreserve, to: :administrative
def view_access
@@ -45,6 +45,12 @@ def role
use.capitalize
end
+ def file_language
+ return 'No language specified' if languageTag.blank?
+
+ languageTag
+ end
+
def link_attrs
{ item_id: object_id, id: filename }
end
diff --git a/app/components/contents/resource_component.html.erb b/app/components/contents/resource_component.html.erb
index b0ea57f8c5..4b780755f9 100644
--- a/app/components/contents/resource_component.html.erb
+++ b/app/components/contents/resource_component.html.erb
@@ -18,6 +18,7 @@
Width |
<% end %>
Role |
+ Language |
Publish |
Shelve |
Preserve |
diff --git a/app/services/structure_serializer.rb b/app/services/structure_serializer.rb
index 46f1ab97a1..c22b3c53a3 100644
--- a/app/services/structure_serializer.rb
+++ b/app/services/structure_serializer.rb
@@ -2,7 +2,8 @@
class StructureSerializer
HEADERS = %w[druid resource_label resource_type sequence filename file_label publish
- shelve preserve rights_view rights_download rights_location mimetype role].freeze
+ shelve preserve rights_view rights_download rights_location mimetype
+ role file_language].freeze
def self.as_csv(druid, structural)
new(druid, structural).as_csv
@@ -28,7 +29,8 @@ def rows
yield [@druid, resource.label, type(resource), n, file.filename, file.label,
to_yes_no(file.administrative.publish), to_yes_no(file.administrative.shelve),
to_yes_no(file.administrative.sdrPreserve), file.access.view,
- file.access.download, file.access.location, file.hasMimeType, file.use]
+ file.access.download, file.access.location, file.hasMimeType, file.use,
+ file.languageTag]
end
end
end
diff --git a/app/services/structure_updater.rb b/app/services/structure_updater.rb
index cf744b423b..ddc002c448 100644
--- a/app/services/structure_updater.rb
+++ b/app/services/structure_updater.rb
@@ -90,6 +90,7 @@ def update_file(existing_file, row)
)
}
attributes[:use] = row['role'] if row['role'] # nil is not permitted
+ attributes[:languageTag] = row['file_language'] if row['file_language'] # nil is not permitted
existing_file.new(**attributes)
end
diff --git a/spec/components/contents/file_component_spec.rb b/spec/components/contents/file_component_spec.rb
index 3ec8e727ac..4cfe7fa71c 100644
--- a/spec/components/contents/file_component_spec.rb
+++ b/spec/components/contents/file_component_spec.rb
@@ -14,13 +14,15 @@
access:,
administrative: admin,
presentation:,
- use:)
+ use:,
+ languageTag: language_tag)
end
let(:access) { instance_double(Cocina::Models::FileAccess, view: 'world', download: 'stanford') }
let(:admin) { instance_double(Cocina::Models::FileAdministrative, sdrPreserve: true, publish: true, shelve: true) }
let(:presentation) { instance_double(Cocina::Models::Presentation, height: 11_839, width: 19_380) }
let(:use) { 'transcription' }
+ let(:language_tag) { 'en-US' }
context 'with an image fileset' do
it 'renders the component' do
@@ -30,6 +32,7 @@
expect(rendered.to_html).to include 'Stanford'
expect(rendered.to_html).to include 'Transcription'
expect(rendered.to_html).to include '11839 px'
+ expect(rendered.to_html).to include language_tag
end
end
@@ -41,6 +44,14 @@
end
end
+ context 'with no file language set' do
+ let(:language_tag) { nil }
+
+ it 'renders the component' do
+ expect(rendered.to_html).to include 'No language specified'
+ end
+ end
+
context 'with no presentation' do
let(:presentation) { nil }
@@ -74,7 +85,7 @@
instance_double(Cocina::Models::FileAccess, view: 'stanford', location: 'hoover', download: 'location-based')
end
- it 'renders the donwload location' do
+ it 'renders the download location' do
expect(rendered.to_html).to include 'Stanford'
expect(rendered.to_html).to include 'hoover'
end
diff --git a/spec/components/contents/resource_component_spec.rb b/spec/components/contents/resource_component_spec.rb
index a4b81ccdd3..cae2c1084e 100644
--- a/spec/components/contents/resource_component_spec.rb
+++ b/spec/components/contents/resource_component_spec.rb
@@ -46,6 +46,7 @@
expect(rendered.to_html).to include 'Type'
expect(rendered.to_html).to include 'Height'
expect(rendered.to_html).to include 'Width'
+ expect(rendered.to_html).to include 'Language'
end
end
diff --git a/spec/services/structure_serializer_spec.rb b/spec/services/structure_serializer_spec.rb
index d6dcf53039..0768b811a8 100644
--- a/spec/services/structure_serializer_spec.rb
+++ b/spec/services/structure_serializer_spec.rb
@@ -54,7 +54,7 @@
it 'serializes to CSV' do
expect(csv).to eq <<~CSV
- druid,resource_label,resource_type,sequence,filename,file_label,publish,shelve,preserve,rights_view,rights_download,rights_location,mimetype,role
+ druid,resource_label,resource_type,sequence,filename,file_label,publish,shelve,preserve,rights_view,rights_download,rights_location,mimetype,role,file_language
CSV
end
end
@@ -251,11 +251,11 @@
it 'serializes to CSV' do
expect(csv).to eq <<~CSV
- druid,resource_label,resource_type,sequence,filename,file_label,publish,shelve,preserve,rights_view,rights_download,rights_location,mimetype,role
- #{bare_druid},Image 1,image,1,bb045jk9908_0001.tiff,bb045jk9908_0001.tiff,no,no,yes,world,world,,image/tiff,
- #{bare_druid},Image 1,image,1,bb045jk9908_0001.jp2,bb045jk9908_0001.jp2,yes,yes,no,world,world,,image/jp2,
- #{bare_druid},Image 2,image,2,bb045jk9908_0002.tiff,bb045jk9908_0002.tiff,no,no,yes,world,world,,image/tiff,
- #{bare_druid},Image 2,image,2,bb045jk9908_0002.jp2,bb045jk9908_0002.jp2,yes,yes,no,location-based,location-based,music,image/jp2,
+ druid,resource_label,resource_type,sequence,filename,file_label,publish,shelve,preserve,rights_view,rights_download,rights_location,mimetype,role,file_language
+ #{bare_druid},Image 1,image,1,bb045jk9908_0001.tiff,bb045jk9908_0001.tiff,no,no,yes,world,world,,image/tiff,,
+ #{bare_druid},Image 1,image,1,bb045jk9908_0001.jp2,bb045jk9908_0001.jp2,yes,yes,no,world,world,,image/jp2,,
+ #{bare_druid},Image 2,image,2,bb045jk9908_0002.tiff,bb045jk9908_0002.tiff,no,no,yes,world,world,,image/tiff,,
+ #{bare_druid},Image 2,image,2,bb045jk9908_0002.jp2,bb045jk9908_0002.jp2,yes,yes,no,location-based,location-based,music,image/jp2,,
CSV
end
end
diff --git a/spec/services/structure_updater_spec.rb b/spec/services/structure_updater_spec.rb
index 65bc8a1dda..4a9b726c87 100644
--- a/spec/services/structure_updater_spec.rb
+++ b/spec/services/structure_updater_spec.rb
@@ -206,8 +206,8 @@
context 'with valid csv that has file properties changed' do
let(:csv) do
<<~CSV
- druid,resource_label,resource_type,sequence,filename,file_label,publish,shelve,preserve,rights_view,rights_download,rights_location,mimetype,role
- #{bare_druid},Image 1,image,1,bb045jk9908_0001.tiff,bb045jk9908_0001.tiff,yes,yes,yes,stanford,stanford,,image/one,
+ druid,resource_label,resource_type,sequence,filename,file_label,publish,shelve,preserve,rights_view,rights_download,rights_location,mimetype,role,file_language
+ #{bare_druid},Image 1,image,1,bb045jk9908_0001.tiff,bb045jk9908_0001.tiff,yes,yes,yes,stanford,stanford,,image/one,,en-US
#{bare_druid},Image 1,image,1,bb045jk9908_0001.jp2,bb045jk9908_0001.jp2,yes,yes,no,world,world,,image/two,transcription
#{bare_druid},Image 2,image,2,bb045jk9908_0002.tiff,bb045jk9908_0002.tiff,yes,yes,yes,stanford,none,,image/three,
#{bare_druid},Image 2,image,2,CCTV新闻联播文本数据-20060615-20220630-Stanford University.xlsx,CCTV新闻联播文本数据-20060615-20220630-Stanford University.xlsx,yes,yes,no,location-based,location-based,music,image/four,
@@ -237,8 +237,8 @@
nil], ['world', 'world', nil], ['stanford', 'none', nil], %w[location-based location-based music]
]
- use = new_files.map(&:use)
- expect(use).to eq [nil, 'transcription', nil, nil]
+ expect(new_files.map(&:use)).to eq [nil, 'transcription', nil, nil]
+ expect(new_files.map(&:languageTag)).to eq ['en-US', nil, nil, nil]
end
it 'produces valid cocina' do