Add language detection (#1772)
* Add language detection via WhatLanguage and (de)serialization of it through Atom * Fix default language in ProcessFeedService * Re-add newline before 'react-rails' Gem to fix groupings Fixes Code Climate issue
This commit is contained in:
parent
6d70a80263
commit
e4af4898de
7 changed files with 23 additions and 4 deletions
|
@ -119,6 +119,7 @@ class ProcessFeedService < BaseService
|
|||
spoiler_text: content_warning(entry),
|
||||
created_at: published(entry),
|
||||
reply: thread?(entry),
|
||||
language: content_language(entry),
|
||||
visibility: visibility_scope(entry)
|
||||
)
|
||||
|
||||
|
@ -238,6 +239,10 @@ class ProcessFeedService < BaseService
|
|||
xml.at_xpath('./xmlns:content', xmlns: TagManager::XMLNS).content
|
||||
end
|
||||
|
||||
def content_language(xml = @xml)
|
||||
xml.at_xpath('./xmlns:content', xmlns: TagManager::XMLNS)['xml:lang']&.presence || 'en'
|
||||
end
|
||||
|
||||
def content_warning(xml = @xml)
|
||||
xml.at_xpath('./xmlns:summary', xmlns: TagManager::XMLNS)&.content || ''
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue